Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2014-09-01 14:54:37 +0000
committerMickael ADAM2014-09-03 14:49:05 +0000
commit377cc40520d3a41d022d78c6a54afe25b5b6d213 (patch)
treef3fcdba0c2d4c2e6cab2a7de9aac53ba1a03ebc8
parent9d8ed1a8d2e8fdd460959696489f6979f4d140a6 (diff)
downloadorg.eclipse.papyrus-377cc40520d3a41d022d78c6a54afe25b5b6d213.tar.gz
org.eclipse.papyrus-377cc40520d3a41d022d78c6a54afe25b5b6d213.tar.xz
org.eclipse.papyrus-377cc40520d3a41d022d78c6a54afe25b5b6d213.zip
440201: [Diagram] Class diagram shapes shall be refactored
https://bugs.eclipse.org/bugs/show_bug.cgi?id=440201 Patch Set 1: - Apply new classFigure and classEditPart to profile diagram to avoid error. - Generate code with new formatter and cleaner. Patch Set 2: - add mask label feature to customize the floating label. - regenerate profile diagram code to fix some issues Change-Id: I6d52866088a11f5ef2bc07b4b68d229fab65ddea Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/BorderDisplayEditPolicy.java27
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java173
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java80
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/FloatingLabelEditPolicy.java248
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java325
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF181
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/figure/StereotypeFigure.java74
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/model/profilediagram.gmfgen12
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationBranchReorientCommand.java354
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationNodeCreateCommand.java226
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationReorientCommand.java354
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassCreateCommandCN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassPropertyCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentAnnotatedElementCreateCommand.java211
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentAnnotatedElementReorientCommand.java327
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentCreateCommandCN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentEditPartCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintConstrainedElementCreateCommand.java211
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintConstrainedElementReorientCommand.java327
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintCreateCommandCN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ContextLinkCreateCommand.java212
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ContextLinkReorientCommand.java327
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeCreateCommandCN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeOperationCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypePropertyCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyBranchCreateCommand.java335
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyBranchReorientCommand.java366
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyCreateCommand.java335
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyNodeCreateCommand.java226
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyReorientCommand.java366
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ElementImportCreateCommand.java337
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ElementImportReorientCommand.java346
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationCreateCommandCN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationLiteralCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ExtensionReorientCommand.java354
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/GeneralizationCreateCommand.java259
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/GeneralizationReorientCommand.java336
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/MetaclassCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/MetaclassCreateCommandCN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandCN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandTN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageCreateCommand.java228
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageCreateCommandCN.java228
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageImportCreateCommand.java333
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageImportReorientCommand.java346
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PrimitiveTypeCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PrimitiveTypeCreateCommandCN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileApplicationCreateCommand.java333
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileApplicationReorientCommand.java346
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileCreateCommandCN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileCreateCommandTN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ShortCutDiagramCreateCommand.java190
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/StereotypeCreateCommand.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/StereotypeCreateCommandCN.java230
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AppliedStereotypeElementImportEditPart.java1576
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationAppliedStereotypeEditPart.java1562
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchEditPart.java246
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchMultiplicityEditPart.java1566
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchRoleEditPart.java1566
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationEditPart.java304
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationMultiplicitySourceEditPart.java1580
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationMultiplicityTargetEditPart.java1580
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationNameEditPart.java1576
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationNodeEditPart.java387
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationRoleSourceEditPart.java1566
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationRoleTargetEditPart.java1566
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassAttributeCompartmentEditPart.java276
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassAttributeCompartmentEditPartCN.java276
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassEditPart.java644
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassEditPartCN.java638
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassNameEditPart.java1693
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassNameEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationCompartmentEditPart.java276
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationCompartmentEditPartCN.java276
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationEditPart.java1671
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassPropertyEditPart.java1671
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentBodyEditPart.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentBodyEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentEditPart.java545
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentEditPartCN.java545
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintBodyEditPart.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintBodyEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintEditPart.java561
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintEditPartCN.java553
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPart.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeAttributeCompartmentEditPart.java278
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeAttributeCompartmentEditPartCN.java278
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeEditPart.java665
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeEditPartCN.java659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeNameEditPart.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeNameEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationCompartmentEditPart.java278
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationCompartmentEditPartCN.java278
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationEditPart.java1671
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypePropertyEditPart.java1671
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyAppliedStereotypeEditPart.java1562
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyEditPart.java248
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyNameEditPart.java1576
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyNodeEditPart.java476
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DiagramNameEditPart.java1653
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java1576
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportEditPart.java248
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEditPart.java631
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEditPartCN.java627
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEnumerationLiteralCompartmentEditPart.java278
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEnumerationLiteralCompartmentEditPartCN.java278
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationLiteralEditPart.java1661
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationNameEditPart.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationNameEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/GeneralizationAppliedStereotypeEditPart.java1562
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/GeneralizationEditPart.java239
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassEditPart.java571
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassEditPartCN.java571
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassNameEditPart.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassNameEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelEditPartCN.java585
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelEditPartTN.java585
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelNameEditPart.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelNameEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelPackageableElementCompartmentEditPartCN.java264
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelPackageableElementCompartmentEditPartTN.java264
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MultiDependencyLabelEditPart.java1623
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageEditPart.java585
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageEditPartCN.java593
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageImportAppliedStereotypeEditPart.java1562
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageImportEditPart.java235
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageNameEditPart.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageNameEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackagePackageableElementCompartmentEditPart.java260
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackagePackageableElementCompartmentEditPartCN.java260
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeEditPart.java553
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeEditPartCN.java553
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeNameEditPart.java1693
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeNameEditPartCN.java1693
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileEditPartCN.java585
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileEditPartTN.java585
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileNameEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileNameEditPartTN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfilePackageableElementCompartmentEditPartCN.java260
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfilePackageableElementCompartmentEditPartTN.java260
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ShortCutDiagramEditPart.java536
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeAttributeCompartmentEditPart.java278
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeAttributeCompartmentEditPartCN.java278
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeEditPart.java683
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeEditPartCN.java683
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeNameEditPart.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeNameEditPartCN.java1659
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeOperationCompartmentEditPart.java278
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeOperationCompartmentEditPartCN.java278
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/UMLEditPartFactory.java625
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationBranchItemSemanticEditPolicy.java609
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationItemSemanticEditPolicy.java609
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationNodeItemSemanticEditPolicy.java629
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassItemSemanticEditPolicyCN.java772
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassOperationItemSemanticEditPolicy.java122
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassPropertyItemSemanticEditPolicy.java122
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClasseItemSemanticEditPolicy.java772
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/CommentEditPartItemSemanticEditPolicy.java334
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/CommentItemSemanticEditPolicyCN.java334
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ConstraintItemSemanticEditPolicy.java492
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ConstraintItemSemanticEditPolicyCN.java492
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeItemSemanticEditPolicy.java743
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeItemSemanticEditPolicyCN.java743
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeOperationItemSemanticEditPolicy.java122
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypePropertyItemSemanticEditPolicy.java122
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyBranchItemSemanticEditPolicy.java436
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyItemSemanticEditPolicy.java436
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyNodeItemSemanticEditPolicy.java456
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ElementImportItemSemanticEditPolicy.java301
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationItemSemanticEditPolicy.java705
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationItemSemanticEditPolicyCN.java705
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationLiteralItemSemanticEditPolicy.java122
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ExtensionItemSemanticEditPolicy.java609
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/GeneralizationItemSemanticEditPolicy.java301
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/MetaclassItemSemanticEditPolicy.java658
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/MetaclassItemSemanticEditPolicyCN.java658
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ModelItemSemanticEditPolicyCN.java1089
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ModelItemSemanticEditPolicyTN.java1089
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageImportItemSemanticEditPolicy.java301
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageItemSemanticEditPolicy.java1147
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageItemSemanticEditPolicyCN.java1233
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PrimitiveTypeItemSemanticEditPolicy.java629
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PrimitiveTypeItemSemanticEditPolicyCN.java629
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileApplicationItemSemanticEditPolicy.java301
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileItemSemanticEditPolicyCN.java1212
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileItemSemanticEditPolicyTN.java1212
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ShortCutDiagramItemSemanticEditPolicy.java122
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/StereotypeItemSemanticEditPolicy.java772
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/StereotypeItemSemanticEditPolicyCN.java772
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLBaseItemSemanticEditPolicy.java1553
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLTextNonResizableEditPolicy.java484
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLTextSelectionEditPolicy.java449
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/navigator/UMLDomainNavigatorContentProvider.java500
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/navigator/UMLNavigatorContentProvider.java528
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/parsers/MessageFormatParser.java411
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/DiagramEditorContextMenuProvider.java120
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLCreationWizard.java342
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLCreationWizardPage.java194
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramContentInitializer.java1587
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditor.java1074
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditorPlugin.java555
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditorUtil.java697
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramUpdater.java7829
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDocumentProvider.java2016
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLInitDiagramFileAction.java202
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLNewDiagramFileWizard.java366
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLVisualIDRegistry.java2382
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/ValidateAction.java568
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/preferences/DiagramPreferenceInitializer.java94
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/ElementInitializers.java198
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLEditPartProvider.java62
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLElementTypes.java1166
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLMarkerNavigationProvider.java189
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLParserProvider.java2072
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLValidationDecoratorProvider.java145
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLViewProvider.java2803
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/sheet/UMLPropertySection.java64
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/sheet/UMLSheetLabelProvider.java178
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ICustomAppearance.java318
225 files changed, 83175 insertions, 79277 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/BorderDisplayEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/BorderDisplayEditPolicy.java
index 87368a43a9e..2cd9f0d95ba 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/BorderDisplayEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/BorderDisplayEditPolicy.java
@@ -22,6 +22,7 @@ import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.draw2d.Border;
import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -162,31 +163,31 @@ public class BorderDisplayEditPolicy extends GraphicalEditPolicyEx implements IC
BooleanValueStyle displayBorderStyle = findDisplayBorderStyle(view);
- //if not diplayBorder
+ // if not diplayBorder
if (displayBorderStyle != null && !displayBorderStyle.isBooleanValue()) {
if (defaultBorder == null) {
defaultBorder = getPrimaryShape().getBorder();
}
getPrimaryShape().setBorder(null);
- } else {//if diplayBorder
+ } else {// if diplayBorder
if (defaultBorder != null) {
getPrimaryShape().setBorder(defaultBorder);
}
defaultBorder = null;
- //If the shape is a compartment and it's the first one, set border to null.
- if(getPrimaryShape() instanceof ResizableCompartmentFigure) {
+ // If the shape is a compartment and it's the first one, set border to null.
+ if (getPrimaryShape() instanceof ResizableCompartmentFigure) {
- //Get all visible compartment
+ // Get all visible compartment
final List<View> allVisibleCompartments = getAllVisibleCompartments(view, getHost().getParent());
- //If the view is the first compartment set border to null
- if(allVisibleCompartments.size() > 0 && allVisibleCompartments.get(0).equals(view)) {
+ // If the view is the first compartment set border to null
+ if (allVisibleCompartments.size() > 0 && allVisibleCompartments.get(0).equals(view)) {
getPrimaryShape().setBorder(null);
} else {
- if(getPrimaryShape().getBorder() == null) {
- getPrimaryShape().setBorder(new OneLineBorder());
- }
- }
+ if (getPrimaryShape().getBorder() == null) {
+ getPrimaryShape().setBorder(new OneLineBorder(2, PositionConstants.TOP));
+ }
+ }
}
}
}
@@ -197,9 +198,9 @@ public class BorderDisplayEditPolicy extends GraphicalEditPolicyEx implements IC
* @param view
*
* @param editpart
- * an editpart
+ * an editpart
* @param includeTitleCompartment
- * if <code>true</code> we return the title compartment too
+ * if <code>true</code> we return the title compartment too
* @return all the displayed compartments for the EditPart
*/
public static List<View> getAllVisibleCompartments(View view, EditPart editpart) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java
index 6964c855862..a9a298218df 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java
@@ -1,80 +1,93 @@
-/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editparts;
-
-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
-import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * The Class FloatingNameEditPart.
- */
-public class FloatingLabelEditPart extends LabelEditPart {
-
- /** The Constant DISPLAY_FLOATING_NAME. */
- private static final String DISPLAY_FLOATING_LABEL = "displayFloatingLabel";
-
-
- /** The Constant DEFAULT_LABEL_DISPLAYED. */
- private static final boolean DEFAULT_LABEL_DISPLAYED = false;
-
- /**
- * Instantiates a new floating name edit part.
- *
- * @param view
- * the view
- */
- public FloatingLabelEditPart(View view) {
- super(view);
- }
-
- /**
- * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#refreshVisibility()
- *
- */
- @Override
- protected void refreshVisibility() {
- super.refreshVisibility();
- //get the value of the CSS property
- BooleanValueStyle isLabelDisplayedValue = (BooleanValueStyle)((View)((View)getModel()).eContainer()).getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), getDisplayFloatingLabel());
-
- //if the property exist set the visibility of the floating name
- boolean isLabelDisplayed;
- if(isLabelDisplayedValue == null) {
- isLabelDisplayed = getDefaultLabelDisplayedValue();
- } else {
- isLabelDisplayed = isLabelDisplayedValue.isBooleanValue();
- }
- getFigure().setVisible(isLabelDisplayed);
- }
-
- /**
- * Gets the default label displayed value.
- *
- * @return the default label displayed value
- */
- protected boolean getDefaultLabelDisplayedValue() {
- return DEFAULT_LABEL_DISPLAYED;
- }
-
- /**
- * Gets the display floating label.
- *
- * @return the display floating label
- */
- public static String getDisplayFloatingLabel() {
- return DISPLAY_FLOATING_LABEL;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.editparts;
+
+import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
+import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.FloatingLabelEditPolicy;
+
+/**
+ * The Class FloatingNameEditPart.
+ */
+public class FloatingLabelEditPart extends LabelEditPart {
+
+ /** The Constant DISPLAY_FLOATING_NAME. */
+ private static final String DISPLAY_FLOATING_LABEL = "displayFloatingLabel";
+
+
+ /** The Constant DEFAULT_LABEL_DISPLAYED. */
+ private static final boolean DEFAULT_LABEL_DISPLAYED = false;
+
+ /**
+ * Instantiates a new floating label edit part.
+ *
+ * @param view
+ * the view
+ */
+ public FloatingLabelEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart#createDefaultEditPolicies()
+ *
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ // installEditPolicy(org.eclipse.papyrus.uml.diagram.common.editpolicies.ExternalLabelDisplayEditPolicy.EXTERNAL_LABEL_POLICY, new ExternalLabelDisplayEditPolicy());
+ installEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL, new FloatingLabelEditPolicy());
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#refreshVisibility()
+ *
+ */
+ @Override
+ protected void refreshVisibility() {
+ super.refreshVisibility();
+ // get the value of the CSS property
+ BooleanValueStyle isLabelDisplayedValue = (BooleanValueStyle) ((View) ((View) getModel()).eContainer()).getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), getDisplayFloatingLabel());
+
+ // if the property exist set the visibility of the floating label
+ boolean isLabelDisplayed;
+ if (isLabelDisplayedValue == null) {
+ isLabelDisplayed = getDefaultLabelDisplayedValue();
+ } else {
+ isLabelDisplayed = isLabelDisplayedValue.isBooleanValue();
+ }
+ getFigure().setVisible(isLabelDisplayed);
+ }
+
+ /**
+ * Gets the default label displayed value.
+ *
+ * @return the default label displayed value
+ */
+ protected boolean getDefaultLabelDisplayedValue() {
+ return DEFAULT_LABEL_DISPLAYED;
+ }
+
+ /**
+ * Gets the display floating label.
+ *
+ * @return the display floating label
+ */
+ public static String getDisplayFloatingLabel() {
+ return DISPLAY_FLOATING_LABEL;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
index a1cccdd79ec..9746921f754 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
@@ -26,13 +26,13 @@ import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEd
public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
/** The Constant FLOATING_NAME_OFFSET_HEIGHT. */
- protected static final String FLOATING_NAME_OFFSET_HEIGHT = "floatingNameOffsetHeight";
+ protected static final String FLOATING_LABEL_OFFSET_HEIGHT = "floatingLabelOffsetHeight";
/** The Constant FLOATING_NAME_OFFSET_WIDTH. */
- protected static final String FLOATING_NAME_OFFSET_WIDTH = "floatingNameOffsetWidth";
+ protected static final String FLOATING_LABEL_OFFSET_WIDTH = "floatingLabelOffsetWidth";
/** CSS boolean property controlling whether label should be constrained. */
- public static final String FLOATING_NAME_CONSTRAINED = "isFloatingNameConstrained";
+ public static final String FLOATING_LABEL_CONSTRAINED = "isFloatingLabelConstrained";
/** CSS boolean property controlling whether. */
public static final String RADIUS_WIDTH = "radiusWidth";
@@ -43,11 +43,11 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
/** CSS boolean property controlling whether. */
public static final String IS_OVAL = "isOval";
- private static final boolean DEFAULT_IS_FLOATING_NAME_CONSTRAINED = false;
+ private static final boolean DEFAULT_IS_FLOATING_LABEL_CONSTRAINED = false;
- private static final int DEFAULT_FLOATING_NAME_OFFSET_WIDTH = 0;
+ private static final int DEFAULT_FLOATING_LABEL_OFFSET_WIDTH = 0;
- private static final int DEFAULT_FLOATING_NAME_OFFSET_HEIGHT = 0;
+ private static final int DEFAULT_FLOATING_LABEL_OFFSET_HEIGHT = 0;
private static final int DEFAULT_CORNER_WIDTH = 0;
@@ -59,7 +59,7 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
* Instantiates a new rounded compartment edit part.
*
* @param view
- * the view
+ * the view
*/
public RoundedCompartmentEditPart(View view) {
super(view);
@@ -69,7 +69,7 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
@Override
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
- //Install Edit Policy to Hide/show compartment, in particular for the symbol compartment
+ // Install Edit Policy to Hide/show compartment, in particular for the symbol compartment
installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
}
@@ -90,32 +90,32 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
* Refresh floating name.
*/
protected void refreshFloatingName() {
- if(getPrimaryShape() instanceof IRoundedRectangleFigure) {
- //The figure
- IRoundedRectangleFigure roundedRectangleFigure = (IRoundedRectangleFigure)getPrimaryShape();
+ if (getPrimaryShape() instanceof IRoundedRectangleFigure) {
+ // The figure
+ IRoundedRectangleFigure roundedRectangleFigure = (IRoundedRectangleFigure) getPrimaryShape();
- //Get CSS value for the name attached properties
- BooleanValueStyle isNameConstrainedValue = (BooleanValueStyle)((View)getModel()).getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), FLOATING_NAME_CONSTRAINED);
+ // Get CSS value for the name attached properties
+ BooleanValueStyle isNameConstrainedValue = (BooleanValueStyle) ((View) getModel()).getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), FLOATING_LABEL_CONSTRAINED);
boolean isNameConstrained;
- //if no css property set to default value
- if(isNameConstrainedValue == null) {
+ // if no css property set to default value
+ if (isNameConstrainedValue == null) {
isNameConstrained = getDefaultIsFloatingNameConstrained();
} else {
isNameConstrained = isNameConstrainedValue.isBooleanValue();
}
- //Set the name attached properties in figure
+ // Set the name attached properties in figure
roundedRectangleFigure.setFloatingNameConstrained(isNameConstrained);
- //get Offset
- //get CSS the value of offset Width
- IntValueStyle offsetWidth = (IntValueStyle)((View)getModel()).getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), FLOATING_NAME_OFFSET_WIDTH);
+ // get Offset
+ // get CSS the value of offset Width
+ IntValueStyle offsetWidth = (IntValueStyle) ((View) getModel()).getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), FLOATING_LABEL_OFFSET_WIDTH);
int width = offsetWidth != null ? offsetWidth.getIntValue() : getDefaultFloatingNameOffsetWidth();
- //get CSS the value of offset Height
- IntValueStyle offsetHeight = (IntValueStyle)((View)getModel()).getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), FLOATING_NAME_OFFSET_HEIGHT);
+ // get CSS the value of offset Height
+ IntValueStyle offsetHeight = (IntValueStyle) ((View) getModel()).getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), FLOATING_LABEL_OFFSET_HEIGHT);
int height = offsetHeight != null ? offsetHeight.getIntValue() : getDefaultFloatingNameOffsetHeight();
- //Set the floating name offset
+ // Set the floating name offset
roundedRectangleFigure.setFloatingNameOffset(new Dimension(width, height));
}
@@ -128,7 +128,7 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
* @return the default is name constrained
*/
protected boolean getDefaultIsFloatingNameConstrained() {
- return DEFAULT_IS_FLOATING_NAME_CONSTRAINED;
+ return DEFAULT_IS_FLOATING_LABEL_CONSTRAINED;
}
/**
@@ -137,7 +137,7 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
* @return the default floating name offset height
*/
protected int getDefaultFloatingNameOffsetHeight() {
- return DEFAULT_FLOATING_NAME_OFFSET_HEIGHT;
+ return DEFAULT_FLOATING_LABEL_OFFSET_HEIGHT;
}
/**
@@ -146,28 +146,28 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
* @return the default floating name offset width
*/
protected int getDefaultFloatingNameOffsetWidth() {
- return DEFAULT_FLOATING_NAME_OFFSET_WIDTH;
+ return DEFAULT_FLOATING_LABEL_OFFSET_WIDTH;
}
/**
* Refresh radius.
*/
protected void refreshRadius() {
- if(getPrimaryShape() instanceof IRoundedRectangleFigure) {
- //The figure
- IRoundedRectangleFigure roundedRectangleFigure = (IRoundedRectangleFigure)getPrimaryShape();
+ if (getPrimaryShape() instanceof IRoundedRectangleFigure) {
+ // The figure
+ IRoundedRectangleFigure roundedRectangleFigure = (IRoundedRectangleFigure) getPrimaryShape();
Dimension radiusDimension = new Dimension();
- //get CSS the value of radius Width
- IntValueStyle radiusWidth = (IntValueStyle)((View)getModel()).getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), RADIUS_WIDTH);
+ // get CSS the value of radius Width
+ IntValueStyle radiusWidth = (IntValueStyle) ((View) getModel()).getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), RADIUS_WIDTH);
radiusDimension.width = radiusWidth != null ? radiusWidth.getIntValue() : getDefaultCornerWidth();
- //get CSS the value of radius Height
- IntValueStyle radiusHeight = (IntValueStyle)((View)getModel()).getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), RADIUS_HEIGHT);
+ // get CSS the value of radius Height
+ IntValueStyle radiusHeight = (IntValueStyle) ((View) getModel()).getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), RADIUS_HEIGHT);
radiusDimension.height = radiusHeight != null ? radiusHeight.getIntValue() : getDefaultCornerHeight();
- //Set the corner dimension
+ // Set the corner dimension
roundedRectangleFigure.setCornerDimensions(radiusDimension);
}
}
@@ -194,18 +194,18 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
* Refresh oval.
*/
protected void refreshOval() {
- if(getPrimaryShape() instanceof IRoundedRectangleFigure) {
- //The figure
- IRoundedRectangleFigure roundedRectangleFigure = (IRoundedRectangleFigure)getPrimaryShape();
- //get the CSS value of isOval
- BooleanValueStyle isOvalValue = (BooleanValueStyle)((View)getModel()).getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), IS_OVAL);
+ if (getPrimaryShape() instanceof IRoundedRectangleFigure) {
+ // The figure
+ IRoundedRectangleFigure roundedRectangleFigure = (IRoundedRectangleFigure) getPrimaryShape();
+ // get the CSS value of isOval
+ BooleanValueStyle isOvalValue = (BooleanValueStyle) ((View) getModel()).getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), IS_OVAL);
boolean isOval;
- if(isOvalValue == null) {
+ if (isOvalValue == null) {
isOval = getDefaultIsOvalValue();
} else {
isOval = isOvalValue.isBooleanValue();
}
- //Set isOval
+ // Set isOval
roundedRectangleFigure.setOval(isOval);
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/FloatingLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/FloatingLabelEditPolicy.java
new file mode 100644
index 00000000000..86da3847ba3
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/FloatingLabelEditPolicy.java
@@ -0,0 +1,248 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.editpolicies;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.papyrus.uml.diagram.common.helper.FloatingLabelHelper;
+import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
+import org.eclipse.uml2.uml.InstanceSpecification;
+import org.eclipse.uml2.uml.MultiplicityElement;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Signal;
+import org.eclipse.uml2.uml.TypedElement;
+import org.eclipse.uml2.uml.UMLPackage;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Specific edit policy for label displaying stereotypes and their properties for edges representing
+ * UML elements.
+ */
+public class FloatingLabelEditPolicy extends AbstractMaskManagedEditPolicy {
+
+ /**
+ * Creates a new PropertyLabelEditPolicy.
+ */
+ public FloatingLabelEditPolicy() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addAdditionalListeners() {
+ super.addAdditionalListeners();
+ NamedElement umlElement = getUMLElement();
+ // check host semantic element is not null
+ if (umlElement == null) {
+ Activator.log.error("No semantic element present when adding listeners in FloatingLabelEditPolicy", null);
+ return;
+ }
+ // adds a listener to the element itself, and to linked elements, like Type
+ if (umlElement instanceof TypedElement) {
+ if (((TypedElement) umlElement).getType() != null) {
+ getDiagramEventBroker().addNotificationListener(((TypedElement) umlElement).getType(), this);
+ }
+ }
+ if (umlElement instanceof MultiplicityElement) {
+ getDiagramEventBroker().addNotificationListener(((MultiplicityElement) umlElement).getUpperValue(), this);
+ getDiagramEventBroker().addNotificationListener(((MultiplicityElement) umlElement).getLowerValue(), this);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Collection<String> getDefaultDisplayValue() {
+ NamedElement umlElement = getUMLElement();
+ if (umlElement != null) {
+
+ /**
+ * default uml operation display.
+ */
+ if (umlElement instanceof Operation) {
+ return ICustomAppearance.DEFAULT_UML_OPERATION;
+ }
+
+ /**
+ * default uml Port ins composite diagrams.
+ */
+ if (umlElement instanceof Port) {
+ return ICustomAppearance.DEFAULT_UML_PORT;
+ }
+
+ /**
+ * default uml Parameter in composite diagrams.
+ */
+ if (umlElement instanceof Parameter) {
+ return ICustomAppearance.DEFAULT_UML_PARAMETER;
+ }
+
+ /**
+ * default uml instancespecification .
+ */
+ if (umlElement instanceof InstanceSpecification) {
+ return ICustomAppearance.DEFAULT_UML_INSTANCESPECIFICATION;
+ }
+
+ /**
+ * default uml Signal .
+ */
+ if (umlElement instanceof Signal) {
+ return Arrays.asList(ICustomAppearance.DISP_NAME, ICustomAppearance.DISP_TYPE);
+ }
+
+ }
+ return ICustomAppearance.DEFAULT_UML_FLOATING_LABEL;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map<String, String> getMasks() {
+ return FloatingLabelHelper.getInstance().getMasks();
+ }
+
+ /**
+ * {@inheritedDoc}.
+ *
+ * @return the UML element
+ */
+ @Override
+ public NamedElement getUMLElement() {
+ EObject element = super.getUMLElement();
+ if (element instanceof NamedElement) {
+ return (NamedElement) element;
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritedDoc}.
+ *
+ * @param notification
+ * the notification
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ super.notifyChanged(notification);
+ // change the label of the figure managed by the host edit part (managed by the parent edit
+ // part in general...)
+ // it must be changed only if:
+ // - the annotation corresponding to the display of the stereotype changes
+ // - the stereotype application list has changed
+ Object object = notification.getNotifier();
+ NamedElement property = getUMLElement();
+ if (object == null || property == null) {
+ return;
+ }
+ if (notification.getFeature().equals(UMLPackage.eINSTANCE.getLiteralInteger_Value())) {
+ refreshDisplay();
+ } else if (notification.getFeature().equals(UMLPackage.eINSTANCE.getLiteralUnlimitedNatural_Value())) {
+ refreshDisplay();
+ }
+ if (object.equals(property)) {
+ notifyNamedElementChanged(property, notification);
+ }
+ if (isMaskManagedAnnotation(object)) {
+ refreshDisplay();
+ }
+ if (isRemovedMaskManagedLabelAnnotation(object, notification)) {
+ refreshDisplay();
+ }
+ }
+
+ /**
+ * notifies that the named element has changed.
+ *
+ * @param namedElement
+ * the property that has changed
+ * @param notification
+ * the notification send when the element has been changed
+ */
+ protected void notifyNamedElementChanged(NamedElement namedElement, Notification notification) {
+ switch (notification.getFeatureID(NamedElement.class)) {
+ case UMLPackage.NAMED_ELEMENT__NAME:
+ refreshDisplay();
+ break;
+ case UMLPackage.NAMED_ELEMENT__VISIBILITY:
+ refreshDisplay();
+ break;
+ default:
+ // does nothing in other cases
+ break;
+ }
+ }
+
+ /**
+ * Returns the view controlled by the host edit part.
+ *
+ * @return the view controlled by the host edit part
+ */
+ @Override
+ protected View getView() {
+ if (getHost().getModel() instanceof View) {
+ if (((View) getHost().getModel()).eContainer() instanceof View) {
+ return (View) ((View) getHost().getModel()).eContainer();
+ }
+ return null;
+ }
+ return null;
+ }
+
+
+ /**
+ * Refreshes the display of the edit part.
+ */
+ @Override
+ public void refreshDisplay() {
+ // calls the helper for this edit Part
+ FloatingLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void removeAdditionalListeners() {
+ super.removeAdditionalListeners();
+ NamedElement umlElement = getUMLElement();
+ if (umlElement == null) {
+ // check semantic element is not null and this is really an instance of NamedElement
+ return;
+ }
+ // remove listener to the element itself, and to linked elements, like Type
+ if (umlElement instanceof TypedElement) {
+ if (((TypedElement) umlElement).getType() != null) {
+ getDiagramEventBroker().removeNotificationListener(((TypedElement) umlElement).getType(), this);
+ }
+ }
+ if (umlElement instanceof MultiplicityElement) {
+ getDiagramEventBroker().removeNotificationListener(((MultiplicityElement) umlElement).getUpperValue(), this);
+ getDiagramEventBroker().removeNotificationListener(((MultiplicityElement) umlElement).getLowerValue(), this);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java
new file mode 100644
index 00000000000..05014b9ec21
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java
@@ -0,0 +1,325 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.helper;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.tools.utils.CollaborationUseUtil;
+import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
+import org.eclipse.papyrus.uml.tools.utils.InstanceSpecificationUtil;
+import org.eclipse.papyrus.uml.tools.utils.MultiplicityElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.OperationUtil;
+import org.eclipse.papyrus.uml.tools.utils.ParameterUtil;
+import org.eclipse.papyrus.uml.tools.utils.PortUtil;
+import org.eclipse.papyrus.uml.tools.utils.PropertyUtil;
+import org.eclipse.papyrus.uml.tools.utils.SignalUtil;
+import org.eclipse.papyrus.uml.tools.utils.TypeUtil;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.CollaborationUse;
+import org.eclipse.uml2.uml.InstanceSpecification;
+import org.eclipse.uml2.uml.MultiplicityElement;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Signal;
+import org.eclipse.uml2.uml.TemplateParameter;
+import org.eclipse.uml2.uml.TypedElement;
+
+//TODO Check for usefull property to display
+
+/**
+ * Helper for labels displaying {@link NamedElement}.
+ */
+public class FloatingLabelHelper extends StereotypedElementLabelHelper {
+
+ // Einstance
+ /** The label helper. */
+ private static FloatingLabelHelper labelHelper;
+
+ /**
+ * Gets the single instance of FloatingLabelHelper.
+ *
+ * @return single instance of FloatingLabelHelper
+ */
+ public static FloatingLabelHelper getInstance() {
+ if (labelHelper == null) {
+ labelHelper = new FloatingLabelHelper();
+ }
+ return labelHelper;
+ }
+
+ /** Map for masks. */
+ protected final Map<String, String> masks = new HashMap<String, String>();
+
+ /**
+ * Instantiates a new floating label helper.
+ */
+ protected FloatingLabelHelper() {
+ // initialize the map
+
+ /**
+ * Style constant for visibility display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_VISIBILITY, "Visibility");
+
+ /**
+ * Style constant for isDerive display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_DERIVE, "Derived");
+
+ /**
+ * Style constant for name display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_NAME, "Name");
+
+ /**
+ * Style constant for type display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_TYPE, "Type");
+
+ /**
+ * Style constant for multiplicity display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_MULTIPLICITY, "Multiplicity");
+
+ /**
+ * Style constant for default value display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_DEFAULT_VALUE, "Default Value");
+
+ /**
+ * Style constant for modifiers display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_MODIFIERS, "Modifiers");
+
+ /** Style constant for carriage return in labels */
+ masks.put(ICustomAppearance.DISP_MULTI_LINE, "Multiline");
+
+ /** Style constant for operation#parameter direction display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_DIRECTION, "Parameters Direction");
+
+ /** Style constant for direction display in labels */
+ masks.put(ICustomAppearance.DISP_DIRECTION, "Direction");
+
+ /** Style constant for operation#parameter name display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_NAME, "Parameters Name");
+
+ /** Style constant for operation#parameter type display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_TYPE, "Parameters Type");
+
+ /** Style constant for operation#parameter multiplicity display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_MULTIPLICITY, "Parameters Multiplicity");
+
+ /** Style constant for operation#parameter default value display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_DEFAULT, "Parameters Default");
+
+ /** Style constant for operation#parameter modifiers display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_MODIFIERS, "Parameters Modifiers");
+
+ /** Style constant for return type display in labels */
+ masks.put(ICustomAppearance.DISP_RT_TYPE, "returnType");
+
+ /** Style constant for return multiplicity display in labels */
+ masks.put(ICustomAppearance.DISP_RT_MULTIPLICITY, "Return Multiplicity");
+
+ /** Style constant for conjugated labels */
+ masks.put(ICustomAppearance.DISP_CONJUGATED, "Conjugated");
+ }
+
+ /**
+ * Computes the label that should be displayed by the figure managed by this
+ * edit part.
+ *
+ * @param editPart
+ * the edit part that controls the {@link NamedElement} to be
+ * displayed
+ * @return the label corresponding to the specific display of the property
+ * ("default" display given by preferences or specific display given
+ * by eAnnotation).
+ */
+ @Override
+ protected String elementLabel(GraphicalEditPart editPart) {
+ IMaskManagedLabelEditPolicy policy = (IMaskManagedLabelEditPolicy) editPart.getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (policy == null) {
+ policy = (IMaskManagedLabelEditPolicy) editPart.getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+
+ Collection<String> displayValue = Collections.emptySet();
+
+ if (policy != null) {
+ displayValue = policy.getCurrentDisplayValue();
+ }
+
+ return parseString(editPart, displayValue);
+ }
+
+ /**
+ * Parses the string.
+ *
+ * @param editPart
+ * the edit part
+ * @param displayValue
+ * the display value
+ * @return the string
+ */
+ protected String parseString(GraphicalEditPart editPart, Collection<String> displayValue) {
+ NamedElement namedElement = getUMLElement(editPart);
+
+ if (namedElement != null) {
+ return getCustomLabel(namedElement, displayValue);
+ }
+
+ return "";
+ }
+
+
+ /**
+ * Returns the map of masks used to display a {@link NamedElement}.
+ *
+ * @return the {@link Map} of masks used to display a {@link NamedElement}
+ */
+ public Map<String, String> getMasks() {
+ return masks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NamedElement getUMLElement(GraphicalEditPart editPart) {
+ if (editPart.getModel() instanceof View) {
+ View view = (View) editPart.getModel();
+ if (view.getElement() instanceof NamedElement) {
+ return (NamedElement) view.getElement();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * return the custom label of the property, given UML2 specification and a custom style.
+ *
+ * @param namedElement
+ * the integer representing the style of the label
+ * @param maskValues
+ * the mask values
+ * @return the string corresponding to the label of the property
+ */
+ public static String getCustomLabel(NamedElement namedElement, Collection<String> maskValues) {
+
+ // Use of specific existing custom label
+
+ // use CollaborationUse custom label
+ if (namedElement instanceof CollaborationUse) {
+ return CollaborationUseUtil.getCustomLabel((CollaborationUse) namedElement, maskValues);
+ }
+
+ // use InstanceSpecification custom label
+ if (namedElement instanceof InstanceSpecification) {
+ return InstanceSpecificationUtil.getCustomLabel((InstanceSpecification) namedElement, maskValues);
+ }
+
+ // use Operation custom label
+ if (namedElement instanceof Operation) {
+ return OperationUtil.getCustomLabel((Operation) namedElement, maskValues);
+ }
+
+ // use Parameter custom label
+ if (namedElement instanceof Parameter) {
+ return ParameterUtil.getCustomLabel((Parameter) namedElement, maskValues);
+ }
+
+ // use Signal custom label
+ if (namedElement instanceof Signal) {
+ return SignalUtil.getCustomLabel((Signal) namedElement, maskValues);
+ }
+
+ // use Port custom label
+ if (namedElement instanceof Port) {
+ return PortUtil.getCustomLabel((Port) namedElement, maskValues);
+ }
+
+ // use Property custom label
+ if (namedElement instanceof Property) {
+ return PropertyUtil.getCustomLabel((Property) namedElement, maskValues);
+ }
+ // TODO add others usefull properties
+
+ // default custom label
+ StringBuffer buffer = new StringBuffer();
+
+ // visibility
+ if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
+ buffer.append(" ");
+ buffer.append(NamedElementUtil.getVisibilityAsSign(namedElement));
+ }
+
+ // derived property for association
+ if (namedElement instanceof Association) {
+ if (maskValues.contains(ICustomAppearance.DISP_DERIVE)) {
+ if (((Association) namedElement).isDerived()) {
+ buffer.append("/");
+ }
+ }
+ }
+ // name
+ if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
+ buffer.append(" ");
+ buffer.append(namedElement.getName());
+ }
+
+ // Type of TypedElement
+ if (namedElement instanceof TypedElement) {
+ if (maskValues.contains(ICustomAppearance.DISP_TYPE)) {
+ // type
+ if (((TypedElement) namedElement).getType() != null) {
+ buffer.append(": " + ((TypedElement) namedElement).getType().getName());
+ } else {
+ buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
+ }
+ }
+ }
+
+ // Multiplicity
+ if (namedElement instanceof MultiplicityElement) {
+ if (maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY)) {
+ // multiplicity -> do not display [1]
+ String multiplicity = MultiplicityElementUtil.getMultiplicityAsString((MultiplicityElement) namedElement);
+ buffer.append(multiplicity);
+ }
+ }
+
+ // Template Parameter(not sure of the uml element
+ if (namedElement instanceof TemplateParameter) {
+ if (maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) {
+ // default value
+ if (((TemplateParameter) namedElement).getDefault() != null) {
+ buffer.append(" = ");
+ buffer.append(((TemplateParameter) namedElement).getDefault());
+ }
+ }
+ }
+
+ return buffer.toString();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
index 25a00cf4fab..4c0e0af7389 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
@@ -1,92 +1,89 @@
-Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.uml.diagram.profile,
- org.eclipse.papyrus.uml.diagram.profile.custom.commands,
- org.eclipse.papyrus.uml.diagram.profile.custom.edit.parts,
- org.eclipse.papyrus.uml.diagram.profile.custom.factory,
- org.eclipse.papyrus.uml.diagram.profile.custom.figure,
- org.eclipse.papyrus.uml.diagram.profile.custom.helper,
- org.eclipse.papyrus.uml.diagram.profile.custom.messages,
- org.eclipse.papyrus.uml.diagram.profile.custom.policies,
- org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic,
- org.eclipse.papyrus.uml.diagram.profile.custom.preferences,
- org.eclipse.papyrus.uml.diagram.profile.custom.providers,
- org.eclipse.papyrus.uml.diagram.profile.custom.requests,
- org.eclipse.papyrus.uml.diagram.profile.edit.commands,
- org.eclipse.papyrus.uml.diagram.profile.edit.helpers,
- org.eclipse.papyrus.uml.diagram.profile.edit.parts,
- org.eclipse.papyrus.uml.diagram.profile.edit.policies,
- org.eclipse.papyrus.uml.diagram.profile.navigator,
- org.eclipse.papyrus.uml.diagram.profile.parsers,
- org.eclipse.papyrus.uml.diagram.profile.part,
- org.eclipse.papyrus.uml.diagram.profile.preferences,
- org.eclipse.papyrus.uml.diagram.profile.providers,
- org.eclipse.papyrus.uml.diagram.profile.service,
- org.eclipse.papyrus.uml.diagram.profile.sheet
-Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .
-Bundle-Name: %pluginName
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.1",
- org.eclipse.papyrus.uml.diagram.common;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.1",
- org.eclipse.papyrus.uml.profile;bundle-version="1.0.1",
- org.eclipse.core.expressions,
- org.eclipse.papyrus.infra.services.edit;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.emf.appearance;bundle-version="1.0.1",
- org.eclipse.papyrus.uml.appearance;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.services.validation;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.core;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.gmfdiag.navigation;bundle-version="1.0.1",
- org.eclipse.papyrus.uml.tools.utils;bundle-version="1.0.1",
- org.eclipse.ui.ide;bundle-version="3.8.0",
- org.eclipse.papyrus.infra.extendedtypes;bundle-version="1.0.1",
- org.eclipse.papyrus.uml.tools;bundle-version="1.0.1",
- org.eclipse.gmf.tooling.runtime;bundle-version="3.0.0",
- org.eclipse.uml2.uml.edit;bundle-version="4.0.100",
- org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.7.0",
- org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.7.0",
- org.eclipse.ui.navigator;bundle-version="3.5.200",
- org.eclipse.ui.navigator.resources;bundle-version="3.4.400",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.widgets;bundle-version="1.0.1",
- org.eclipse.gmf.runtime.diagram.ui.providers;bundle-version="1.7.0",
- org.eclipse.papyrus.infra.emf;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.emf.diagram.common;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.1",
- org.eclipse.core.runtime,
- org.eclipse.core.resources,
- org.eclipse.jface,
- org.eclipse.ui.views,
- 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.papyrus.uml.service.types;bundle-version="1.0.1",
- org.eclipse.gmf.runtime.diagram.ui.providers.ide,
- org.eclipse.gmf.runtime.diagram.ui.render,
- org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide,
- org.eclipse.draw2d,
- org.eclipse.gmf.runtime.draw2d.ui,
- org.eclipse.uml2.uml,
- org.eclipse.emf.ecore,
- org.eclipse.emf.ecore.edit,
- org.eclipse.ocl.ecore,
- org.eclipse.emf.validation,
- org.eclipse.gef,
- org.eclipse.papyrus.infra.viewpoints.configuration;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="1.0.1"
-Bundle-Vendor: %providerName
-Eclipse-LazyStart: true
-Bundle-Version: 1.0.1.qualifier
-Bundle-Activator: org.eclipse.papyrus.uml.diagram.profile.part.UMLDiag
- ramEditorPlugin
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.profile;singleton
- :=true
-
+Manifest-Version: 1.0
+Export-Package: org.eclipse.papyrus.uml.diagram.profile,
+ org.eclipse.papyrus.uml.diagram.profile.custom.commands,
+ org.eclipse.papyrus.uml.diagram.profile.custom.edit.parts,
+ org.eclipse.papyrus.uml.diagram.profile.custom.factory,
+ org.eclipse.papyrus.uml.diagram.profile.custom.figure,
+ org.eclipse.papyrus.uml.diagram.profile.custom.helper,
+ org.eclipse.papyrus.uml.diagram.profile.custom.messages,
+ org.eclipse.papyrus.uml.diagram.profile.custom.policies,
+ org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic,
+ org.eclipse.papyrus.uml.diagram.profile.custom.preferences,
+ org.eclipse.papyrus.uml.diagram.profile.custom.providers,
+ org.eclipse.papyrus.uml.diagram.profile.custom.requests,
+ org.eclipse.papyrus.uml.diagram.profile.edit.commands,
+ org.eclipse.papyrus.uml.diagram.profile.edit.helpers,
+ org.eclipse.papyrus.uml.diagram.profile.edit.parts,
+ org.eclipse.papyrus.uml.diagram.profile.edit.policies,
+ org.eclipse.papyrus.uml.diagram.profile.navigator,
+ org.eclipse.papyrus.uml.diagram.profile.parsers,
+ org.eclipse.papyrus.uml.diagram.profile.part,
+ org.eclipse.papyrus.uml.diagram.profile.preferences,
+ org.eclipse.papyrus.uml.diagram.profile.providers,
+ org.eclipse.papyrus.uml.diagram.profile.service,
+ org.eclipse.papyrus.uml.diagram.profile.sheet
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.1",
+ org.eclipse.papyrus.uml.diagram.common;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.1",
+ org.eclipse.papyrus.uml.profile;bundle-version="1.0.1",
+ org.eclipse.core.expressions,
+ org.eclipse.papyrus.infra.services.edit;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.emf.appearance;bundle-version="1.0.1",
+ org.eclipse.papyrus.uml.appearance;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.services.validation;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.gmfdiag.navigation;bundle-version="1.0.1",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="1.0.1",
+ org.eclipse.ui.ide;bundle-version="3.8.0",
+ org.eclipse.papyrus.infra.extendedtypes;bundle-version="1.0.1",
+ org.eclipse.papyrus.uml.tools;bundle-version="1.0.1",
+ org.eclipse.gmf.tooling.runtime;bundle-version="3.0.0",
+ org.eclipse.uml2.uml.edit;bundle-version="4.0.100",
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.7.0",
+ org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.7.0",
+ org.eclipse.ui.navigator;bundle-version="3.5.200",
+ org.eclipse.ui.navigator.resources;bundle-version="3.4.400",
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.widgets;bundle-version="1.0.1",
+ org.eclipse.gmf.runtime.diagram.ui.providers;bundle-version="1.7.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.emf.diagram.common;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.1",
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.jface,
+ org.eclipse.ui.views,
+ 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.papyrus.uml.service.types;bundle-version="1.0.1",
+ org.eclipse.gmf.runtime.diagram.ui.providers.ide,
+ org.eclipse.gmf.runtime.diagram.ui.render,
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide,
+ org.eclipse.draw2d,
+ org.eclipse.gmf.runtime.draw2d.ui,
+ org.eclipse.uml2.uml,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.edit,
+ org.eclipse.ocl.ecore,
+ org.eclipse.emf.validation,
+ org.eclipse.gef,
+ org.eclipse.papyrus.infra.viewpoints.configuration;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="1.0.1"
+Bundle-Vendor: %providerName
+Eclipse-LazyStart: true
+Bundle-Version: 1.0.1.qualifier
+Bundle-Activator: org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.profile; singleton:=true
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/figure/StereotypeFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/figure/StereotypeFigure.java
index 871a40c0791..8a56eff8313 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/figure/StereotypeFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/figure/StereotypeFigure.java
@@ -1,37 +1,37 @@
-/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.profile.custom.figure;
-
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
-
-/**
- * Figure for representation of Stereotype
- */
-public class StereotypeFigure extends ClassifierFigure {
-
- /**
- * the tag
- */
- private static String TAG_LABEL = "Stereotype"; //$NON-NLS-1$
-
- /**
- *
- * Constructor.
- *
- */
- public StereotypeFigure() {
- super(TAG_LABEL);
-
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.profile.custom.figure;
+
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure;
+
+/**
+ * Figure for representation of Stereotype
+ */
+public class StereotypeFigure extends ClassFigure {
+
+ /**
+ * the tag
+ */
+ private static String TAG_LABEL = "Stereotype"; //$NON-NLS-1$
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public StereotypeFigure() {
+ super(TAG_LABEL);
+
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/model/profilediagram.gmfgen b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/model/profilediagram.gmfgen
index fe874882551..d6b44f9ac68 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/model/profilediagram.gmfgen
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/model/profilediagram.gmfgen
@@ -457,7 +457,7 @@
metamodelType="/0/@diagram/@topLevelNodes.3/@elementType"/>
<viewmap
xsi:type="gmfgen:FigureViewmap"
- figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure">
+ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure">
<attributes
xsi:type="gmfgen:DefaultSizeAttributes"
width="100"
@@ -538,7 +538,7 @@
editHelperClassName="MetaclassEditHelper"/>
<viewmap
xsi:type="gmfgen:FigureViewmap"
- figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure">
+ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure">
<attributes
xsi:type="gmfgen:DefaultSizeAttributes"
width="100"
@@ -1303,7 +1303,7 @@
editHelperClassName="ClassEditHelper"/>
<viewmap
xsi:type="gmfgen:FigureViewmap"
- figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure">
+ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure">
<attributes
xsi:type="gmfgen:DefaultSizeAttributes"
width="100"
@@ -1383,7 +1383,7 @@
metamodelType="/0/@diagram/@childNodes.8/@elementType"/>
<viewmap
xsi:type="gmfgen:FigureViewmap"
- figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure">
+ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure">
<attributes
xsi:type="gmfgen:DefaultSizeAttributes"
width="100"
@@ -3672,11 +3672,11 @@
comment="Manage the class"
genView="/0/@diagram/@topLevelNodes.4 /0/@diagram/@topLevelNodes.2 /0/@diagram/@childNodes.6 /0/@diagram/@childNodes.8"
name="Extended class editpart"
- superOwnedEditPart="org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart">
+ superOwnedEditPart="org.eclipse.papyrus.uml.diagram.common.editparts.ClassEditPart">
<propRefreshHook
comment="set the figure active when the feature of the of a class is true"
triggeringCondition="resolveSemanticElement().equals(event.getNotifier()) &amp;&amp; (event.getFeature() instanceof org.eclipse.emf.ecore.EAttribute)&amp;&amp; ((org.eclipse.emf.ecore.EAttribute) (event.getFeature())).getName().equals(&quot;isActive&quot;)"
- action="((org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure) getFigure()).setActive(event.getNewBooleanValue())"/>
+ action="((org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure) getFigure()).setActive(event.getNewBooleanValue())"/>
</extensionNodes>
<extensionNodes
xsi:type="papyrusgmfgenextension:ExtendedGenView"
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationBranchReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationBranchReorientCommand.java
index eb280837ad8..219c2074b02 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationBranchReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationBranchReorientCommand.java
@@ -1,175 +1,179 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Association;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Type;
-
-/**
- * @generated
- */
-public class AssociationBranchReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public AssociationBranchReorientCommand(ReorientRelationshipRequest request) {
- super(request.getLabel(), request.getRelationship(), request);
- reorientDirection = request.getDirection();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == getElementToEdit() instanceof Association) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof Type && newEnd instanceof Type)) {
- return false;
- }
- if (getLink().getEndTypes().size() != 1) {
- return false;
- }
- Type target = getLink().getEndTypes().get(0);
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistAssociation_4019(container, getLink(), getNewSource(), target);
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof Type && newEnd instanceof Type)) {
- return false;
- }
- if (getLink().getEndTypes().size() != 1) {
- return false;
- }
- Type source = getLink().getEndTypes().get(0);
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistAssociation_4019(container, getLink(), source, getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected Association getLink() {
- return (Association) getElementToEdit();
- }
-
- /**
- * @generated
- */
- protected Type getOldSource() {
- return (Type) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Type getNewSource() {
- return (Type) newEnd;
- }
-
- /**
- * @generated
- */
- protected Type getOldTarget() {
- return (Type) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Type getNewTarget() {
- return (Type) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Type;
+
+/**
+ * @generated
+ */
+public class AssociationBranchReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public AssociationBranchReorientCommand(ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == getElementToEdit() instanceof Association) {
+ 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 Type && newEnd instanceof Type)) {
+ return false;
+ }
+ if (getLink().getEndTypes()
+ .size() != 1) {
+ return false;
+ }
+ Type target = (Type) getLink().getEndTypes()
+ .get(0);
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistAssociation_4019(container, getLink(), getNewSource(), target);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Type && newEnd instanceof Type)) {
+ return false;
+ }
+ if (getLink().getEndTypes()
+ .size() != 1) {
+ return false;
+ }
+ Type source = (Type) getLink().getEndTypes()
+ .get(0);
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistAssociation_4019(container, getLink(), source, getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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 {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Association getLink() {
+ return (Association) getElementToEdit();
+ }
+
+ /**
+ * @generated
+ */
+ protected Type getOldSource() {
+ return (Type) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Type getNewSource() {
+ return (Type) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Type getOldTarget() {
+ return (Type) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Type getNewTarget() {
+ return (Type) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationNodeCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationNodeCreateCommand.java
index 12dfb3ca10d..26242321790 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationNodeCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationNodeCreateCommand.java
@@ -1,113 +1,113 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.uml2.uml.Association;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class AssociationNodeCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public AssociationNodeCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getAssociation());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Association newElement = UMLFactory.eINSTANCE.createAssociation();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Association 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class AssociationNodeCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public AssociationNodeCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getAssociation());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Association newElement = UMLFactory.eINSTANCE.createAssociation();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Association 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationReorientCommand.java
index 993b50d524b..37c976f4a35 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/AssociationReorientCommand.java
@@ -1,175 +1,179 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Association;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Type;
-
-/**
- * @generated
- */
-public class AssociationReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public AssociationReorientCommand(ReorientRelationshipRequest request) {
- super(request.getLabel(), request.getRelationship(), request);
- reorientDirection = request.getDirection();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == getElementToEdit() instanceof Association) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof Type && newEnd instanceof Type)) {
- return false;
- }
- if (getLink().getEndTypes().size() != 1) {
- return false;
- }
- Type target = getLink().getEndTypes().get(0);
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistAssociation_4001(container, getLink(), getNewSource(), target);
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof Type && newEnd instanceof Type)) {
- return false;
- }
- if (getLink().getEndTypes().size() != 1) {
- return false;
- }
- Type source = getLink().getEndTypes().get(0);
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistAssociation_4001(container, getLink(), source, getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected Association getLink() {
- return (Association) getElementToEdit();
- }
-
- /**
- * @generated
- */
- protected Type getOldSource() {
- return (Type) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Type getNewSource() {
- return (Type) newEnd;
- }
-
- /**
- * @generated
- */
- protected Type getOldTarget() {
- return (Type) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Type getNewTarget() {
- return (Type) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Type;
+
+/**
+ * @generated
+ */
+public class AssociationReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public AssociationReorientCommand(ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == getElementToEdit() instanceof Association) {
+ 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 Type && newEnd instanceof Type)) {
+ return false;
+ }
+ if (getLink().getEndTypes()
+ .size() != 1) {
+ return false;
+ }
+ Type target = (Type) getLink().getEndTypes()
+ .get(0);
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistAssociation_4001(container, getLink(), getNewSource(), target);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Type && newEnd instanceof Type)) {
+ return false;
+ }
+ if (getLink().getEndTypes()
+ .size() != 1) {
+ return false;
+ }
+ Type source = (Type) getLink().getEndTypes()
+ .get(0);
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistAssociation_4001(container, getLink(), source, getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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 {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Association getLink() {
+ return (Association) getElementToEdit();
+ }
+
+ /**
+ * @generated
+ */
+ protected Type getOldSource() {
+ return (Type) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Type getNewSource() {
+ return (Type) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Type getOldTarget() {
+ return (Type) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Type getNewTarget() {
+ return (Type) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassCreateCommand.java
index 09fe09c427f..a20f9ab5d4d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ClassCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public ClassCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getClass_());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Class newElement = UMLFactory.eINSTANCE.createClass();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Class_2008(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Class 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ClassCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public ClassCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getClass_());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Class newElement = UMLFactory.eINSTANCE.createClass();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Class_2008(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Class 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassCreateCommandCN.java
index 12c7283a85b..c36b7e8698f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassCreateCommandCN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ClassCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public ClassCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getClass_());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Class newElement = UMLFactory.eINSTANCE.createClass();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Class_3010(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Class 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ClassCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public ClassCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getClass_());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Class newElement = UMLFactory.eINSTANCE.createClass();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Class_3010(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Class 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java
index 13dc9132577..ad29fa620ae 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ClassOperationCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public ClassOperationCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getOperation());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Operation newElement = UMLFactory.eINSTANCE.createOperation();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Class qualifiedTarget = (Class) target;
- qualifiedTarget.getOwnedOperations().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Operation_3020(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Operation 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ClassOperationCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public ClassOperationCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getOperation());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Operation newElement = UMLFactory.eINSTANCE.createOperation();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Class qualifiedTarget = (Class) target;
+ qualifiedTarget.getOwnedOperations()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Operation_3020(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Operation 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassPropertyCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassPropertyCreateCommand.java
index 7680e73ac4d..89be034e0a9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassPropertyCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassPropertyCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.StructuredClassifier;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ClassPropertyCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public ClassPropertyCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getProperty());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Property newElement = UMLFactory.eINSTANCE.createProperty();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- StructuredClassifier qualifiedTarget = (StructuredClassifier) target;
- qualifiedTarget.getOwnedAttributes().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Property_3002(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Property 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.StructuredClassifier;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ClassPropertyCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public ClassPropertyCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getProperty());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Property newElement = UMLFactory.eINSTANCE.createProperty();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ StructuredClassifier qualifiedTarget = (StructuredClassifier) target;
+ qualifiedTarget.getOwnedAttributes()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Property_3002(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Property 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentAnnotatedElementCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentAnnotatedElementCreateCommand.java
index 4c29878754c..178df3327fc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentAnnotatedElementCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentAnnotatedElementCreateCommand.java
@@ -1,105 +1,106 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Element;
-
-/**
- * @generated
- */
-public class CommentAnnotatedElementCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- protected final EObject source;
-
- /**
- * @generated
- */
- protected final EObject target;
-
- /**
- * @generated
- */
- public CommentAnnotatedElementCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
- super(request.getLabel(), null, request);
- this.source = source;
- this.target = target;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (source == null && target == null) {
- return false;
- }
- if (source != null && false == source instanceof Comment) {
- return false;
- }
- if (target != null && false == target instanceof Element) {
- 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateCommentAnnotatedElement_1022(getSource(), getTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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().getAnnotatedElements().add(getTarget());
- }
- return CommandResult.newOKCommandResult();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setElementToEdit(EObject element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected Comment getSource() {
- return (Comment) source;
- }
-
- /**
- * @generated
- */
- protected Element getTarget() {
- return (Element) target;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * @generated
+ */
+public class CommentAnnotatedElementCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ protected final EObject source;
+
+ /**
+ * @generated
+ */
+ protected final EObject target;
+
+ /**
+ * @generated
+ */
+ public CommentAnnotatedElementCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof Comment) {
+ return false;
+ }
+ if (target != null && false == target instanceof Element) {
+ 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateCommentAnnotatedElement_1022(getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().getAnnotatedElements()
+ .add(getTarget());
+ }
+ return CommandResult.newOKCommandResult();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Comment getSource() {
+ return (Comment) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected Element getTarget() {
+ return (Element) target;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentAnnotatedElementReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentAnnotatedElementReorientCommand.java
index 8d9207697a9..acbf838cd19 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentAnnotatedElementReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentAnnotatedElementReorientCommand.java
@@ -1,161 +1,166 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Element;
-
-/**
- * @generated
- */
-public class CommentAnnotatedElementReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject referenceOwner;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public CommentAnnotatedElementReorientCommand(ReorientReferenceRelationshipRequest request) {
- super(request.getLabel(), null, request);
- reorientDirection = request.getDirection();
- referenceOwner = request.getReferenceOwner();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == referenceOwner instanceof Comment) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof Element && newEnd instanceof Comment)) {
- return false;
- }
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistCommentAnnotatedElement_1022(getNewSource(), getOldTarget());
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof Element && newEnd instanceof Element)) {
- return false;
- }
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistCommentAnnotatedElement_1022(getOldSource(), getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- getOldSource().getAnnotatedElements().remove(getOldTarget());
- getNewSource().getAnnotatedElements().add(getOldTarget());
- return CommandResult.newOKCommandResult(referenceOwner);
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- getOldSource().getAnnotatedElements().remove(getOldTarget());
- getOldSource().getAnnotatedElements().add(getNewTarget());
- return CommandResult.newOKCommandResult(referenceOwner);
- }
-
- /**
- * @generated
- */
- protected Comment getOldSource() {
- return (Comment) referenceOwner;
- }
-
- /**
- * @generated
- */
- protected Comment getNewSource() {
- return (Comment) newEnd;
- }
-
- /**
- * @generated
- */
- protected Element getOldTarget() {
- return (Element) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Element getNewTarget() {
- return (Element) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * @generated
+ */
+public class CommentAnnotatedElementReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject referenceOwner;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public CommentAnnotatedElementReorientCommand(ReorientReferenceRelationshipRequest request) {
+ super(request.getLabel(), null, request);
+ reorientDirection = request.getDirection();
+ referenceOwner = request.getReferenceOwner();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == referenceOwner instanceof Comment) {
+ 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 Element && newEnd instanceof Comment)) {
+ return false;
+ }
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistCommentAnnotatedElement_1022(getNewSource(), getOldTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Element && newEnd instanceof Element)) {
+ return false;
+ }
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistCommentAnnotatedElement_1022(getOldSource(), getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().getAnnotatedElements()
+ .remove(getOldTarget());
+ getNewSource().getAnnotatedElements()
+ .add(getOldTarget());
+ return CommandResult.newOKCommandResult(referenceOwner);
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getOldSource().getAnnotatedElements()
+ .remove(getOldTarget());
+ getOldSource().getAnnotatedElements()
+ .add(getNewTarget());
+ return CommandResult.newOKCommandResult(referenceOwner);
+ }
+
+ /**
+ * @generated
+ */
+ protected Comment getOldSource() {
+ return (Comment) referenceOwner;
+ }
+
+ /**
+ * @generated
+ */
+ protected Comment getNewSource() {
+ return (Comment) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Element getOldTarget() {
+ return (Element) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Element getNewTarget() {
+ return (Element) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentCreateCommandCN.java
index 5d10c6c99e1..bba05e3b573 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentCreateCommandCN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class CommentCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public CommentCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getComment());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Comment newElement = UMLFactory.eINSTANCE.createComment();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Element qualifiedTarget = (Element) target;
- qualifiedTarget.getOwnedComments().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Comment_1007(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Comment 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class CommentCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public CommentCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getComment());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Comment newElement = UMLFactory.eINSTANCE.createComment();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Element qualifiedTarget = (Element) target;
+ qualifiedTarget.getOwnedComments()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Comment_1007(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Comment 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentEditPartCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentEditPartCreateCommand.java
index 66c14fd99a1..719a6604107 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentEditPartCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/CommentEditPartCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class CommentEditPartCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public CommentEditPartCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getComment());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Comment newElement = UMLFactory.eINSTANCE.createComment();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Element qualifiedTarget = (Element) target;
- qualifiedTarget.getOwnedComments().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Comment_1002(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Comment 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class CommentEditPartCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public CommentEditPartCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getComment());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Comment newElement = UMLFactory.eINSTANCE.createComment();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Element qualifiedTarget = (Element) target;
+ qualifiedTarget.getOwnedComments()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Comment_1002(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Comment 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintConstrainedElementCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintConstrainedElementCreateCommand.java
index 28f504ff782..bd387fcdccc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintConstrainedElementCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintConstrainedElementCreateCommand.java
@@ -1,105 +1,106 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Element;
-
-/**
- * @generated
- */
-public class ConstraintConstrainedElementCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- protected final EObject source;
-
- /**
- * @generated
- */
- protected final EObject target;
-
- /**
- * @generated
- */
- public ConstraintConstrainedElementCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
- super(request.getLabel(), null, request);
- this.source = source;
- this.target = target;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (source == null && target == null) {
- return false;
- }
- if (source != null && false == source instanceof Constraint) {
- return false;
- }
- if (target != null && false == target instanceof Element) {
- 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateConstraintConstrainedElement_4014(getSource(), getTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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().getConstrainedElements().add(getTarget());
- }
- return CommandResult.newOKCommandResult();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setElementToEdit(EObject element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected Constraint getSource() {
- return (Constraint) source;
- }
-
- /**
- * @generated
- */
- protected Element getTarget() {
- return (Element) target;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * @generated
+ */
+public class ConstraintConstrainedElementCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ protected final EObject source;
+
+ /**
+ * @generated
+ */
+ protected final EObject target;
+
+ /**
+ * @generated
+ */
+ public ConstraintConstrainedElementCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof Constraint) {
+ return false;
+ }
+ if (target != null && false == target instanceof Element) {
+ 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateConstraintConstrainedElement_4014(getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().getConstrainedElements()
+ .add(getTarget());
+ }
+ return CommandResult.newOKCommandResult();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Constraint getSource() {
+ return (Constraint) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected Element getTarget() {
+ return (Element) target;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintConstrainedElementReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintConstrainedElementReorientCommand.java
index e3e4095cfda..53a668676b6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintConstrainedElementReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintConstrainedElementReorientCommand.java
@@ -1,161 +1,166 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Element;
-
-/**
- * @generated
- */
-public class ConstraintConstrainedElementReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject referenceOwner;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public ConstraintConstrainedElementReorientCommand(ReorientReferenceRelationshipRequest request) {
- super(request.getLabel(), null, request);
- reorientDirection = request.getDirection();
- referenceOwner = request.getReferenceOwner();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == referenceOwner instanceof Constraint) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof Element && newEnd instanceof Constraint)) {
- return false;
- }
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistConstraintConstrainedElement_4014(getNewSource(), getOldTarget());
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof Element && newEnd instanceof Element)) {
- return false;
- }
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistConstraintConstrainedElement_4014(getOldSource(), getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- getOldSource().getConstrainedElements().remove(getOldTarget());
- getNewSource().getConstrainedElements().add(getOldTarget());
- return CommandResult.newOKCommandResult(referenceOwner);
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- getOldSource().getConstrainedElements().remove(getOldTarget());
- getOldSource().getConstrainedElements().add(getNewTarget());
- return CommandResult.newOKCommandResult(referenceOwner);
- }
-
- /**
- * @generated
- */
- protected Constraint getOldSource() {
- return (Constraint) referenceOwner;
- }
-
- /**
- * @generated
- */
- protected Constraint getNewSource() {
- return (Constraint) newEnd;
- }
-
- /**
- * @generated
- */
- protected Element getOldTarget() {
- return (Element) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Element getNewTarget() {
- return (Element) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * @generated
+ */
+public class ConstraintConstrainedElementReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject referenceOwner;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public ConstraintConstrainedElementReorientCommand(ReorientReferenceRelationshipRequest request) {
+ super(request.getLabel(), null, request);
+ reorientDirection = request.getDirection();
+ referenceOwner = request.getReferenceOwner();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == referenceOwner instanceof Constraint) {
+ 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 Element && newEnd instanceof Constraint)) {
+ return false;
+ }
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistConstraintConstrainedElement_4014(getNewSource(), getOldTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Element && newEnd instanceof Element)) {
+ return false;
+ }
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistConstraintConstrainedElement_4014(getOldSource(), getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().getConstrainedElements()
+ .remove(getOldTarget());
+ getNewSource().getConstrainedElements()
+ .add(getOldTarget());
+ return CommandResult.newOKCommandResult(referenceOwner);
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getOldSource().getConstrainedElements()
+ .remove(getOldTarget());
+ getOldSource().getConstrainedElements()
+ .add(getNewTarget());
+ return CommandResult.newOKCommandResult(referenceOwner);
+ }
+
+ /**
+ * @generated
+ */
+ protected Constraint getOldSource() {
+ return (Constraint) referenceOwner;
+ }
+
+ /**
+ * @generated
+ */
+ protected Constraint getNewSource() {
+ return (Constraint) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Element getOldTarget() {
+ return (Element) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Element getNewTarget() {
+ return (Element) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintCreateCommand.java
index e1765bfc1d2..2bbe33366e9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ConstraintCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public ConstraintCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getConstraint());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Constraint newElement = UMLFactory.eINSTANCE.createConstraint();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Constraint_1014(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Constraint 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ConstraintCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public ConstraintCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getConstraint());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Constraint newElement = UMLFactory.eINSTANCE.createConstraint();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Constraint_1014(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Constraint 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintCreateCommandCN.java
index c69071b237e..3ea37d31640 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ConstraintCreateCommandCN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ConstraintCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public ConstraintCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getConstraint());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Constraint newElement = UMLFactory.eINSTANCE.createConstraint();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Constraint_1028(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Constraint 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ConstraintCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public ConstraintCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getConstraint());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Constraint newElement = UMLFactory.eINSTANCE.createConstraint();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Constraint_1028(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Constraint 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ContextLinkCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ContextLinkCreateCommand.java
index 5567173c68b..45bee73eadc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ContextLinkCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ContextLinkCreateCommand.java
@@ -1,105 +1,107 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Namespace;
-
-/**
- * @generated
- */
-public class ContextLinkCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- protected final EObject source;
-
- /**
- * @generated
- */
- protected final EObject target;
-
- /**
- * @generated
- */
- public ContextLinkCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
- super(request.getLabel(), null, request);
- this.source = source;
- this.target = target;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (source == null && target == null) {
- return false;
- }
- if (source != null && false == source instanceof Constraint) {
- return false;
- }
- if (target != null && false == target instanceof Namespace) {
- 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateConstraintContext_8500(getSource(), getTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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().setContext(getTarget());
- }
- return CommandResult.newOKCommandResult();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setElementToEdit(EObject element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected Constraint getSource() {
- return (Constraint) source;
- }
-
- /**
- * @generated
- */
- protected Namespace getTarget() {
- return (Namespace) target;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Namespace;
+
+/**
+ * @generated
+ */
+public class ContextLinkCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ protected final EObject source;
+
+ /**
+ * @generated
+ */
+ protected final EObject target;
+
+ /**
+ * @generated
+ */
+ public ContextLinkCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof Constraint) {
+ return false;
+ }
+ if (target != null && false == target instanceof Namespace) {
+ 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateConstraintContext_8500(getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().setContext(
+ getTarget()
+ );
+ }
+ return CommandResult.newOKCommandResult();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Constraint getSource() {
+ return (Constraint) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected Namespace getTarget() {
+ return (Namespace) target;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ContextLinkReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ContextLinkReorientCommand.java
index 22d837a81ce..01b77afc031 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ContextLinkReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ContextLinkReorientCommand.java
@@ -1,160 +1,167 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Namespace;
-
-/**
- * @generated
- */
-public class ContextLinkReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject referenceOwner;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public ContextLinkReorientCommand(ReorientReferenceRelationshipRequest request) {
- super(request.getLabel(), null, request);
- reorientDirection = request.getDirection();
- referenceOwner = request.getReferenceOwner();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == referenceOwner instanceof Constraint) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof Namespace && newEnd instanceof Constraint)) {
- return false;
- }
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistConstraintContext_8500(getNewSource(), getOldTarget());
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof Namespace && newEnd instanceof Namespace)) {
- return false;
- }
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistConstraintContext_8500(getOldSource(), getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- getOldSource().setContext(null);
- getNewSource().setContext(getOldTarget());
- return CommandResult.newOKCommandResult(referenceOwner);
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- getOldSource().setContext(getNewTarget());
- return CommandResult.newOKCommandResult(referenceOwner);
- }
-
- /**
- * @generated
- */
- protected Constraint getOldSource() {
- return (Constraint) referenceOwner;
- }
-
- /**
- * @generated
- */
- protected Constraint getNewSource() {
- return (Constraint) newEnd;
- }
-
- /**
- * @generated
- */
- protected Namespace getOldTarget() {
- return (Namespace) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Namespace getNewTarget() {
- return (Namespace) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Namespace;
+
+/**
+ * @generated
+ */
+public class ContextLinkReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject referenceOwner;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public ContextLinkReorientCommand(ReorientReferenceRelationshipRequest request) {
+ super(request.getLabel(), null, request);
+ reorientDirection = request.getDirection();
+ referenceOwner = request.getReferenceOwner();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == referenceOwner instanceof Constraint) {
+ 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 Namespace && newEnd instanceof Constraint)) {
+ return false;
+ }
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistConstraintContext_8500(getNewSource(), getOldTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Namespace && newEnd instanceof Namespace)) {
+ return false;
+ }
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistConstraintContext_8500(getOldSource(), getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().setContext(
+ null
+ );
+ getNewSource().setContext(
+ getOldTarget()
+ );
+ return CommandResult.newOKCommandResult(referenceOwner);
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getOldSource().setContext(
+ getNewTarget()
+ );
+ return CommandResult.newOKCommandResult(referenceOwner);
+ }
+
+ /**
+ * @generated
+ */
+ protected Constraint getOldSource() {
+ return (Constraint) referenceOwner;
+ }
+
+ /**
+ * @generated
+ */
+ protected Constraint getNewSource() {
+ return (Constraint) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Namespace getOldTarget() {
+ return (Namespace) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Namespace getNewTarget() {
+ return (Namespace) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeCreateCommand.java
index f55a3dca83f..181af4ddd59 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.DataType;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class DataTypeCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public DataTypeCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getDataType());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- DataType newElement = UMLFactory.eINSTANCE.createDataType();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_DataType_2010(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(DataType 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class DataTypeCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public DataTypeCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getDataType());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ DataType newElement = UMLFactory.eINSTANCE.createDataType();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_DataType_2010(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(DataType 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeCreateCommandCN.java
index a627bfde473..6f0c5207d6c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeCreateCommandCN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.DataType;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class DataTypeCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public DataTypeCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getDataType());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- DataType newElement = UMLFactory.eINSTANCE.createDataType();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_DataType_3027(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(DataType 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class DataTypeCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public DataTypeCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getDataType());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ DataType newElement = UMLFactory.eINSTANCE.createDataType();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_DataType_3027(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(DataType 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeOperationCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeOperationCreateCommand.java
index ab86954b34c..2e9fdd60bc9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeOperationCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypeOperationCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.DataType;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class DataTypeOperationCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public DataTypeOperationCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getOperation());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Operation newElement = UMLFactory.eINSTANCE.createOperation();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- DataType qualifiedTarget = (DataType) target;
- qualifiedTarget.getOwnedOperations().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Operation_3019(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Operation 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class DataTypeOperationCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public DataTypeOperationCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getOperation());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Operation newElement = UMLFactory.eINSTANCE.createOperation();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ DataType qualifiedTarget = (DataType) target;
+ qualifiedTarget.getOwnedOperations()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Operation_3019(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Operation 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypePropertyCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypePropertyCreateCommand.java
index d56d9daba05..8e84df200c4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypePropertyCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DataTypePropertyCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.DataType;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class DataTypePropertyCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public DataTypePropertyCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getProperty());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Property newElement = UMLFactory.eINSTANCE.createProperty();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- DataType qualifiedTarget = (DataType) target;
- qualifiedTarget.getOwnedAttributes().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Property_3018(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Property 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class DataTypePropertyCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public DataTypePropertyCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getProperty());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Property newElement = UMLFactory.eINSTANCE.createProperty();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ DataType qualifiedTarget = (DataType) target;
+ qualifiedTarget.getOwnedAttributes()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Property_3018(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Property 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyBranchCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyBranchCreateCommand.java
index f110464e89b..5000d0dea1d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyBranchCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyBranchCreateCommand.java
@@ -1,166 +1,169 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Dependency;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-
-/**
- * @generated
- */
-public class DependencyBranchCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- protected final EObject source;
-
- /**
- * @generated
- */
- protected final EObject target;
-
- /**
- * @generated
- */
- protected Package container;
-
- /**
- * @generated
- */
- public DependencyBranchCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
- super(request.getLabel(), null, request);
- this.source = source;
- this.target = target;
- container = deduceContainer(source, target);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (source == null && target == null) {
- return false;
- }
- if (source != null && false == source instanceof NamedElement) {
- return false;
- }
- if (target != null && false == target instanceof NamedElement) {
- 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateDependency_4018(getContainer(), getSource(), getTarget());
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- if (!canExecute()) {
- throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
- }
- Dependency newElement = UMLFactory.eINSTANCE.createDependency();
- getContainer().getPackagedElements().add(newElement);
- newElement.getClients().add(getSource());
- newElement.getSuppliers().add(getTarget());
- ElementInitializers.getInstance().init_Dependency_4018(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Dependency 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
- */
- @Override
- protected void setElementToEdit(EObject element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected NamedElement getSource() {
- return (NamedElement) source;
- }
-
- /**
- * @generated
- */
- protected NamedElement getTarget() {
- return (NamedElement) target;
- }
-
- /**
- * @generated
- */
- public Package getContainer() {
- return container;
- }
-
- /**
- * Default approach is to traverse ancestors of the source to find instance of container.
- * Modify with appropriate logic.
- *
- * @generated
- */
- protected Package 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 Package) {
- return (Package) element;
- }
- }
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * @generated
+ */
+public class DependencyBranchCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ protected final EObject source;
+
+ /**
+ * @generated
+ */
+ protected final EObject target;
+
+ /**
+ * @generated
+ */
+ protected Package container;
+
+ /**
+ * @generated
+ */
+ public DependencyBranchCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ container = deduceContainer(source, target);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof NamedElement) {
+ return false;
+ }
+ if (target != null && false == target instanceof NamedElement) {
+ 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateDependency_4018(getContainer(), getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
+ }
+ Dependency newElement = UMLFactory.eINSTANCE.createDependency();
+ getContainer().getPackagedElements()
+ .add(newElement);
+ newElement.getClients()
+ .add(getSource());
+ newElement.getSuppliers()
+ .add(getTarget());
+ ElementInitializers.getInstance().init_Dependency_4018(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Dependency 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
+ */
+ @Override
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getSource() {
+ return (NamedElement) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getTarget() {
+ return (NamedElement) target;
+ }
+
+ /**
+ * @generated
+ */
+ public Package getContainer() {
+ return container;
+ }
+
+ /**
+ * Default approach is to traverse ancestors of the source to find instance of container.
+ * Modify with appropriate logic.
+ *
+ * @generated
+ */
+ protected Package 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 Package) {
+ return (Package) element;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyBranchReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyBranchReorientCommand.java
index 909cbd7f32a..1b1814cbd17 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyBranchReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyBranchReorientCommand.java
@@ -1,179 +1,187 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Dependency;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Package;
-
-/**
- * @generated
- */
-public class DependencyBranchReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public DependencyBranchReorientCommand(ReorientRelationshipRequest request) {
- super(request.getLabel(), request.getRelationship(), request);
- reorientDirection = request.getDirection();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == getElementToEdit() instanceof Dependency) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof NamedElement && newEnd instanceof NamedElement)) {
- return false;
- }
- if (getLink().getSuppliers().size() != 1) {
- return false;
- }
- NamedElement target = getLink().getSuppliers().get(0);
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistDependency_4018(container, getLink(), getNewSource(), target);
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof NamedElement && newEnd instanceof NamedElement)) {
- return false;
- }
- if (getLink().getClients().size() != 1) {
- return false;
- }
- NamedElement source = getLink().getClients().get(0);
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistDependency_4018(container, getLink(), source, getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- getLink().getClients().remove(getOldSource());
- getLink().getClients().add(getNewSource());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- getLink().getSuppliers().remove(getOldTarget());
- getLink().getSuppliers().add(getNewTarget());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected Dependency getLink() {
- return (Dependency) getElementToEdit();
- }
-
- /**
- * @generated
- */
- protected NamedElement getOldSource() {
- return (NamedElement) oldEnd;
- }
-
- /**
- * @generated
- */
- protected NamedElement getNewSource() {
- return (NamedElement) newEnd;
- }
-
- /**
- * @generated
- */
- protected NamedElement getOldTarget() {
- return (NamedElement) oldEnd;
- }
-
- /**
- * @generated
- */
- protected NamedElement getNewTarget() {
- return (NamedElement) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+
+/**
+ * @generated
+ */
+public class DependencyBranchReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public DependencyBranchReorientCommand(ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == getElementToEdit() instanceof Dependency) {
+ 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 NamedElement && newEnd instanceof NamedElement)) {
+ return false;
+ }
+ if (getLink().getSuppliers()
+ .size() != 1) {
+ return false;
+ }
+ NamedElement target = (NamedElement) getLink().getSuppliers()
+ .get(0);
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistDependency_4018(container, getLink(), getNewSource(), target);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof NamedElement && newEnd instanceof NamedElement)) {
+ return false;
+ }
+ if (getLink().getClients()
+ .size() != 1) {
+ return false;
+ }
+ NamedElement source = (NamedElement) getLink().getClients()
+ .get(0);
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistDependency_4018(container, getLink(), source, getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().getClients()
+ .remove(getOldSource());
+ getLink().getClients()
+ .add(getNewSource());
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getLink().getSuppliers()
+ .remove(getOldTarget());
+ getLink().getSuppliers()
+ .add(getNewTarget());
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected Dependency getLink() {
+ return (Dependency) getElementToEdit();
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getOldSource() {
+ return (NamedElement) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getNewSource() {
+ return (NamedElement) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getOldTarget() {
+ return (NamedElement) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getNewTarget() {
+ return (NamedElement) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyCreateCommand.java
index 5cd81a5a2be..2a444b80765 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyCreateCommand.java
@@ -1,166 +1,169 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Dependency;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-
-/**
- * @generated
- */
-public class DependencyCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- protected final EObject source;
-
- /**
- * @generated
- */
- protected final EObject target;
-
- /**
- * @generated
- */
- protected Package container;
-
- /**
- * @generated
- */
- public DependencyCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
- super(request.getLabel(), null, request);
- this.source = source;
- this.target = target;
- container = deduceContainer(source, target);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (source == null && target == null) {
- return false;
- }
- if (source != null && false == source instanceof NamedElement) {
- return false;
- }
- if (target != null && false == target instanceof NamedElement) {
- 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateDependency_4008(getContainer(), getSource(), getTarget());
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- if (!canExecute()) {
- throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
- }
- Dependency newElement = UMLFactory.eINSTANCE.createDependency();
- getContainer().getPackagedElements().add(newElement);
- newElement.getClients().add(getSource());
- newElement.getSuppliers().add(getTarget());
- ElementInitializers.getInstance().init_Dependency_4008(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Dependency 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
- */
- @Override
- protected void setElementToEdit(EObject element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected NamedElement getSource() {
- return (NamedElement) source;
- }
-
- /**
- * @generated
- */
- protected NamedElement getTarget() {
- return (NamedElement) target;
- }
-
- /**
- * @generated
- */
- public Package getContainer() {
- return container;
- }
-
- /**
- * Default approach is to traverse ancestors of the source to find instance of container.
- * Modify with appropriate logic.
- *
- * @generated
- */
- protected Package 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 Package) {
- return (Package) element;
- }
- }
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * @generated
+ */
+public class DependencyCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ protected final EObject source;
+
+ /**
+ * @generated
+ */
+ protected final EObject target;
+
+ /**
+ * @generated
+ */
+ protected Package container;
+
+ /**
+ * @generated
+ */
+ public DependencyCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ container = deduceContainer(source, target);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof NamedElement) {
+ return false;
+ }
+ if (target != null && false == target instanceof NamedElement) {
+ 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateDependency_4008(getContainer(), getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
+ }
+ Dependency newElement = UMLFactory.eINSTANCE.createDependency();
+ getContainer().getPackagedElements()
+ .add(newElement);
+ newElement.getClients()
+ .add(getSource());
+ newElement.getSuppliers()
+ .add(getTarget());
+ ElementInitializers.getInstance().init_Dependency_4008(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Dependency 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
+ */
+ @Override
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getSource() {
+ return (NamedElement) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getTarget() {
+ return (NamedElement) target;
+ }
+
+ /**
+ * @generated
+ */
+ public Package getContainer() {
+ return container;
+ }
+
+ /**
+ * Default approach is to traverse ancestors of the source to find instance of container.
+ * Modify with appropriate logic.
+ *
+ * @generated
+ */
+ protected Package 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 Package) {
+ return (Package) element;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyNodeCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyNodeCreateCommand.java
index fbd9e6dcc2d..f076ac4f732 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyNodeCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyNodeCreateCommand.java
@@ -1,113 +1,113 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.uml2.uml.Dependency;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class DependencyNodeCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public DependencyNodeCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getDependency());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Dependency newElement = UMLFactory.eINSTANCE.createDependency();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Dependency 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class DependencyNodeCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public DependencyNodeCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getDependency());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Dependency newElement = UMLFactory.eINSTANCE.createDependency();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Dependency 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyReorientCommand.java
index fa21a477254..83fc91e0d07 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/DependencyReorientCommand.java
@@ -1,179 +1,187 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Dependency;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Package;
-
-/**
- * @generated
- */
-public class DependencyReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public DependencyReorientCommand(ReorientRelationshipRequest request) {
- super(request.getLabel(), request.getRelationship(), request);
- reorientDirection = request.getDirection();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == getElementToEdit() instanceof Dependency) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof NamedElement && newEnd instanceof NamedElement)) {
- return false;
- }
- if (getLink().getSuppliers().size() != 1) {
- return false;
- }
- NamedElement target = getLink().getSuppliers().get(0);
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistDependency_4008(container, getLink(), getNewSource(), target);
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof NamedElement && newEnd instanceof NamedElement)) {
- return false;
- }
- if (getLink().getClients().size() != 1) {
- return false;
- }
- NamedElement source = getLink().getClients().get(0);
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistDependency_4008(container, getLink(), source, getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- getLink().getClients().remove(getOldSource());
- getLink().getClients().add(getNewSource());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- getLink().getSuppliers().remove(getOldTarget());
- getLink().getSuppliers().add(getNewTarget());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected Dependency getLink() {
- return (Dependency) getElementToEdit();
- }
-
- /**
- * @generated
- */
- protected NamedElement getOldSource() {
- return (NamedElement) oldEnd;
- }
-
- /**
- * @generated
- */
- protected NamedElement getNewSource() {
- return (NamedElement) newEnd;
- }
-
- /**
- * @generated
- */
- protected NamedElement getOldTarget() {
- return (NamedElement) oldEnd;
- }
-
- /**
- * @generated
- */
- protected NamedElement getNewTarget() {
- return (NamedElement) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+
+/**
+ * @generated
+ */
+public class DependencyReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public DependencyReorientCommand(ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == getElementToEdit() instanceof Dependency) {
+ 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 NamedElement && newEnd instanceof NamedElement)) {
+ return false;
+ }
+ if (getLink().getSuppliers()
+ .size() != 1) {
+ return false;
+ }
+ NamedElement target = (NamedElement) getLink().getSuppliers()
+ .get(0);
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistDependency_4008(container, getLink(), getNewSource(), target);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof NamedElement && newEnd instanceof NamedElement)) {
+ return false;
+ }
+ if (getLink().getClients()
+ .size() != 1) {
+ return false;
+ }
+ NamedElement source = (NamedElement) getLink().getClients()
+ .get(0);
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistDependency_4008(container, getLink(), source, getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().getClients()
+ .remove(getOldSource());
+ getLink().getClients()
+ .add(getNewSource());
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getLink().getSuppliers()
+ .remove(getOldTarget());
+ getLink().getSuppliers()
+ .add(getNewTarget());
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected Dependency getLink() {
+ return (Dependency) getElementToEdit();
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getOldSource() {
+ return (NamedElement) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getNewSource() {
+ return (NamedElement) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getOldTarget() {
+ return (NamedElement) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected NamedElement getNewTarget() {
+ return (NamedElement) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ElementImportCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ElementImportCreateCommand.java
index 07ec12483a3..208e12805e6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ElementImportCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ElementImportCreateCommand.java
@@ -1,166 +1,171 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.ElementImport;
-import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.PackageableElement;
-import org.eclipse.uml2.uml.UMLFactory;
-
-/**
- * @generated
- */
-public class ElementImportCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- protected final EObject source;
-
- /**
- * @generated
- */
- protected final EObject target;
-
- /**
- * @generated
- */
- protected Namespace container;
-
- /**
- * @generated
- */
- public ElementImportCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
- super(request.getLabel(), null, request);
- this.source = source;
- this.target = target;
- container = deduceContainer(source, target);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (source == null && target == null) {
- return false;
- }
- if (source != null && false == source instanceof Namespace) {
- return false;
- }
- if (target != null && false == target instanceof PackageableElement) {
- 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateElementImport_1064(getContainer(), getSource(), getTarget());
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- if (!canExecute()) {
- throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
- }
- ElementImport newElement = UMLFactory.eINSTANCE.createElementImport();
- getContainer().getElementImports().add(newElement);
- newElement.setImportingNamespace(getSource());
- newElement.setImportedElement(getTarget());
- ElementInitializers.getInstance().init_ElementImport_1064(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(ElementImport 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
- */
- @Override
- protected void setElementToEdit(EObject element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected Namespace getSource() {
- return (Namespace) source;
- }
-
- /**
- * @generated
- */
- protected PackageableElement getTarget() {
- return (PackageableElement) target;
- }
-
- /**
- * @generated
- */
- public Namespace getContainer() {
- return container;
- }
-
- /**
- * Default approach is to traverse ancestors of the source to find instance of container.
- * Modify with appropriate logic.
- *
- * @generated
- */
- protected Namespace 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 Namespace) {
- return (Namespace) element;
- }
- }
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.ElementImport;
+import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * @generated
+ */
+public class ElementImportCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ protected final EObject source;
+
+ /**
+ * @generated
+ */
+ protected final EObject target;
+
+ /**
+ * @generated
+ */
+ protected Namespace container;
+
+ /**
+ * @generated
+ */
+ public ElementImportCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ container = deduceContainer(source, target);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof Namespace) {
+ return false;
+ }
+ if (target != null && false == target instanceof PackageableElement) {
+ 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateElementImport_1064(getContainer(), getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
+ }
+ ElementImport newElement = UMLFactory.eINSTANCE.createElementImport();
+ getContainer().getElementImports()
+ .add(newElement);
+ newElement.setImportingNamespace(
+ getSource()
+ );
+ newElement.setImportedElement(
+ getTarget()
+ );
+ ElementInitializers.getInstance().init_ElementImport_1064(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(ElementImport 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
+ */
+ @Override
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Namespace getSource() {
+ return (Namespace) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected PackageableElement getTarget() {
+ return (PackageableElement) target;
+ }
+
+ /**
+ * @generated
+ */
+ public Namespace getContainer() {
+ return container;
+ }
+
+ /**
+ * Default approach is to traverse ancestors of the source to find instance of container.
+ * Modify with appropriate logic.
+ *
+ * @generated
+ */
+ protected Namespace 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 Namespace) {
+ return (Namespace) element;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ElementImportReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ElementImportReorientCommand.java
index ef12c06563a..254755ef30e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ElementImportReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ElementImportReorientCommand.java
@@ -1,171 +1,175 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.ElementImport;
-import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.PackageableElement;
-
-/**
- * @generated
- */
-public class ElementImportReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public ElementImportReorientCommand(ReorientRelationshipRequest request) {
- super(request.getLabel(), request.getRelationship(), request);
- reorientDirection = request.getDirection();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == getElementToEdit() instanceof ElementImport) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof Namespace && newEnd instanceof Namespace)) {
- return false;
- }
- PackageableElement target = getLink().getImportedElement();
- if (!(getLink().eContainer() instanceof Namespace)) {
- return false;
- }
- Namespace container = (Namespace) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistElementImport_1064(container, getLink(), getNewSource(), target);
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof PackageableElement && newEnd instanceof PackageableElement)) {
- return false;
- }
- Namespace source = getLink().getImportingNamespace();
- if (!(getLink().eContainer() instanceof Namespace)) {
- return false;
- }
- Namespace container = (Namespace) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistElementImport_1064(container, getLink(), source, getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- getLink().setImportingNamespace(getNewSource());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- getLink().setImportedElement(getNewTarget());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected ElementImport getLink() {
- return (ElementImport) getElementToEdit();
- }
-
- /**
- * @generated
- */
- protected Namespace getOldSource() {
- return (Namespace) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Namespace getNewSource() {
- return (Namespace) newEnd;
- }
-
- /**
- * @generated
- */
- protected PackageableElement getOldTarget() {
- return (PackageableElement) oldEnd;
- }
-
- /**
- * @generated
- */
- protected PackageableElement getNewTarget() {
- return (PackageableElement) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.ElementImport;
+import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.PackageableElement;
+
+/**
+ * @generated
+ */
+public class ElementImportReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public ElementImportReorientCommand(ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == getElementToEdit() instanceof ElementImport) {
+ 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 Namespace && newEnd instanceof Namespace)) {
+ return false;
+ }
+ PackageableElement target = getLink().getImportedElement();
+ if (!(getLink().eContainer() instanceof Namespace)) {
+ return false;
+ }
+ Namespace container = (Namespace) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistElementImport_1064(container, getLink(), getNewSource(), target);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof PackageableElement && newEnd instanceof PackageableElement)) {
+ return false;
+ }
+ Namespace source = getLink().getImportingNamespace();
+ if (!(getLink().eContainer() instanceof Namespace)) {
+ return false;
+ }
+ Namespace container = (Namespace) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistElementImport_1064(container, getLink(), source, getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().setImportingNamespace(
+ getNewSource()
+ );
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getLink().setImportedElement(
+ getNewTarget()
+ );
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected ElementImport getLink() {
+ return (ElementImport) getElementToEdit();
+ }
+
+ /**
+ * @generated
+ */
+ protected Namespace getOldSource() {
+ return (Namespace) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Namespace getNewSource() {
+ return (Namespace) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected PackageableElement getOldTarget() {
+ return (PackageableElement) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected PackageableElement getNewTarget() {
+ return (PackageableElement) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationCreateCommand.java
index 3373c7078d3..d2148605c54 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Enumeration;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class EnumerationCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public EnumerationCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getEnumeration());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Enumeration newElement = UMLFactory.eINSTANCE.createEnumeration();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Enumeration_2006(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Enumeration 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class EnumerationCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public EnumerationCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getEnumeration());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Enumeration newElement = UMLFactory.eINSTANCE.createEnumeration();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Enumeration_2006(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Enumeration 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationCreateCommandCN.java
index 42c08a8a79e..fc4d9cbd17a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationCreateCommandCN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Enumeration;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class EnumerationCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public EnumerationCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getEnumeration());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Enumeration newElement = UMLFactory.eINSTANCE.createEnumeration();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Enumeration_3025(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Enumeration 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class EnumerationCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public EnumerationCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getEnumeration());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Enumeration newElement = UMLFactory.eINSTANCE.createEnumeration();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Enumeration_3025(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Enumeration 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationLiteralCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationLiteralCreateCommand.java
index 260a3de0a0e..6452356a507 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationLiteralCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/EnumerationLiteralCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Enumeration;
-import org.eclipse.uml2.uml.EnumerationLiteral;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class EnumerationLiteralCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public EnumerationLiteralCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getEnumerationLiteral());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- EnumerationLiteral newElement = UMLFactory.eINSTANCE.createEnumerationLiteral();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Enumeration qualifiedTarget = (Enumeration) target;
- qualifiedTarget.getOwnedLiterals().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_EnumerationLiteral_1037(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(EnumerationLiteral 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class EnumerationLiteralCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public EnumerationLiteralCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getEnumerationLiteral());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ EnumerationLiteral newElement = UMLFactory.eINSTANCE.createEnumerationLiteral();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Enumeration qualifiedTarget = (Enumeration) target;
+ qualifiedTarget.getOwnedLiterals()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_EnumerationLiteral_1037(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(EnumerationLiteral 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ExtensionReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ExtensionReorientCommand.java
index 891c4754301..7c0829d56d8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ExtensionReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ExtensionReorientCommand.java
@@ -1,175 +1,179 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Extension;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Property;
-
-/**
- * @generated
- */
-public class ExtensionReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public ExtensionReorientCommand(ReorientRelationshipRequest request) {
- super(request.getLabel(), request.getRelationship(), request);
- reorientDirection = request.getDirection();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == getElementToEdit() instanceof Extension) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof Property && newEnd instanceof Property)) {
- return false;
- }
- Class target = getLink().getMetaclass();
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistExtension_1013(container, getLink(), getNewSource(), target);
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof Class && newEnd instanceof Class)) {
- return false;
- }
- if (getLink().getOwnedEnds().size() != 1) {
- return false;
- }
- Property source = getLink().getOwnedEnds().get(0);
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistExtension_1013(container, getLink(), source, getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- getLink().getOwnedEnds().remove(getOldSource());
- getLink().getOwnedEnds().add(getNewSource());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected Extension getLink() {
- return (Extension) getElementToEdit();
- }
-
- /**
- * @generated
- */
- protected Property getOldSource() {
- return (Property) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Property getNewSource() {
- return (Property) newEnd;
- }
-
- /**
- * @generated
- */
- protected Class getOldTarget() {
- return (Class) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Class getNewTarget() {
- return (Class) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Property;
+
+/**
+ * @generated
+ */
+public class ExtensionReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public ExtensionReorientCommand(ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == getElementToEdit() instanceof Extension) {
+ 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 Property && newEnd instanceof Property)) {
+ return false;
+ }
+ Class target = getLink().getMetaclass();
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistExtension_1013(container, getLink(), getNewSource(), target);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Class && newEnd instanceof Class)) {
+ return false;
+ }
+ if (getLink().getOwnedEnds()
+ .size() != 1) {
+ return false;
+ }
+ Property source = (Property) getLink().getOwnedEnds()
+ .get(0);
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistExtension_1013(container, getLink(), source, getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().getOwnedEnds()
+ .remove(getOldSource());
+ getLink().getOwnedEnds()
+ .add(getNewSource());
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Extension getLink() {
+ return (Extension) getElementToEdit();
+ }
+
+ /**
+ * @generated
+ */
+ protected Property getOldSource() {
+ return (Property) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Property getNewSource() {
+ return (Property) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Class getOldTarget() {
+ return (Class) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Class getNewTarget() {
+ return (Class) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/GeneralizationCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/GeneralizationCreateCommand.java
index 9c79eb55d24..5ae4abd970c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/GeneralizationCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/GeneralizationCreateCommand.java
@@ -1,128 +1,131 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Generalization;
-import org.eclipse.uml2.uml.UMLFactory;
-
-/**
- * @generated
- */
-public class GeneralizationCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- protected final EObject source;
-
- /**
- * @generated
- */
- protected final EObject target;
-
- /**
- * @generated
- */
- public GeneralizationCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
- super(request.getLabel(), null, request);
- this.source = source;
- this.target = target;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (source == null && target == null) {
- return false;
- }
- if (source != null && false == source instanceof Classifier) {
- return false;
- }
- if (target != null && false == target instanceof Classifier) {
- 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateGeneralization_4002(getSource(), getTarget());
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- if (!canExecute()) {
- throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
- }
- Generalization newElement = UMLFactory.eINSTANCE.createGeneralization();
- getSource().getGeneralizations().add(newElement);
- newElement.setGeneral(getTarget());
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Generalization 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
- */
- @Override
- protected void setElementToEdit(EObject element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected Classifier getSource() {
- return (Classifier) source;
- }
-
- /**
- * @generated
- */
- protected Classifier getTarget() {
- return (Classifier) target;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * @generated
+ */
+public class GeneralizationCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ protected final EObject source;
+
+ /**
+ * @generated
+ */
+ protected final EObject target;
+
+ /**
+ * @generated
+ */
+ public GeneralizationCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof Classifier) {
+ return false;
+ }
+ if (target != null && false == target instanceof Classifier) {
+ 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateGeneralization_4002(getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
+ }
+ Generalization newElement = UMLFactory.eINSTANCE.createGeneralization();
+ getSource().getGeneralizations()
+ .add(newElement);
+ newElement.setGeneral(
+ getTarget()
+ );
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Generalization 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
+ */
+ @Override
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Classifier getSource() {
+ return (Classifier) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected Classifier getTarget() {
+ return (Classifier) target;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/GeneralizationReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/GeneralizationReorientCommand.java
index 629b1a3f276..b7413f3b99a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/GeneralizationReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/GeneralizationReorientCommand.java
@@ -1,166 +1,170 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Generalization;
-
-/**
- * @generated
- */
-public class GeneralizationReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public GeneralizationReorientCommand(ReorientRelationshipRequest request) {
- super(request.getLabel(), request.getRelationship(), request);
- reorientDirection = request.getDirection();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == getElementToEdit() instanceof Generalization) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof Classifier && newEnd instanceof Classifier)) {
- return false;
- }
- Classifier target = getLink().getGeneral();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistGeneralization_4002(getLink(), getNewSource(), target);
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof Classifier && newEnd instanceof Classifier)) {
- return false;
- }
- if (!(getLink().eContainer() instanceof Classifier)) {
- return false;
- }
- Classifier source = (Classifier) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistGeneralization_4002(getLink(), source, getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- getOldSource().getGeneralizations().remove(getLink());
- getNewSource().getGeneralizations().add(getLink());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- getLink().setGeneral(getNewTarget());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected Generalization getLink() {
- return (Generalization) getElementToEdit();
- }
-
- /**
- * @generated
- */
- protected Classifier getOldSource() {
- return (Classifier) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Classifier getNewSource() {
- return (Classifier) newEnd;
- }
-
- /**
- * @generated
- */
- protected Classifier getOldTarget() {
- return (Classifier) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Classifier getNewTarget() {
- return (Classifier) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Generalization;
+
+/**
+ * @generated
+ */
+public class GeneralizationReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public GeneralizationReorientCommand(ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == getElementToEdit() instanceof Generalization) {
+ 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 Classifier && newEnd instanceof Classifier)) {
+ return false;
+ }
+ Classifier target = getLink().getGeneral();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistGeneralization_4002(getLink(), getNewSource(), target);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Classifier && newEnd instanceof Classifier)) {
+ return false;
+ }
+ if (!(getLink().eContainer() instanceof Classifier)) {
+ return false;
+ }
+ Classifier source = (Classifier) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistGeneralization_4002(getLink(), source, getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().getGeneralizations()
+ .remove(getLink());
+ getNewSource().getGeneralizations()
+ .add(getLink());
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getLink().setGeneral(
+ getNewTarget()
+ );
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected Generalization getLink() {
+ return (Generalization) getElementToEdit();
+ }
+
+ /**
+ * @generated
+ */
+ protected Classifier getOldSource() {
+ return (Classifier) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Classifier getNewSource() {
+ return (Classifier) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Classifier getOldTarget() {
+ return (Classifier) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Classifier getNewTarget() {
+ return (Classifier) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/MetaclassCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/MetaclassCreateCommand.java
index 15becec2ca1..49380190067 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/MetaclassCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/MetaclassCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class MetaclassCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public MetaclassCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getClass_());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Class newElement = UMLFactory.eINSTANCE.createClass();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Class_1031(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Class 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class MetaclassCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public MetaclassCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getClass_());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Class newElement = UMLFactory.eINSTANCE.createClass();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Class_1031(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Class 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/MetaclassCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/MetaclassCreateCommandCN.java
index b2e42ca66ae..31aae71e451 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/MetaclassCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/MetaclassCreateCommandCN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class MetaclassCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public MetaclassCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getClass_());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Class newElement = UMLFactory.eINSTANCE.createClass();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Class_3028(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Class 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class MetaclassCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public MetaclassCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getClass_());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Class newElement = UMLFactory.eINSTANCE.createClass();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Class_3028(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Class 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandCN.java
index c569827abd0..d4b9dea8b55 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandCN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Model;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ModelCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public ModelCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getModel());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Model newElement = UMLFactory.eINSTANCE.createModel();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Model_1027(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Model 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ModelCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public ModelCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getModel());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Model newElement = UMLFactory.eINSTANCE.createModel();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Model_1027(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Model 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandTN.java
index fea07dff107..f87e624f308 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandTN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Model;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ModelCreateCommandTN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public ModelCreateCommandTN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getModel());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Model newElement = UMLFactory.eINSTANCE.createModel();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Model_2005(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Model 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ModelCreateCommandTN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public ModelCreateCommandTN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getModel());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Model newElement = UMLFactory.eINSTANCE.createModel();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Model_2005(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Model 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageCreateCommand.java
index abac06eb6c7..8373e2ec41d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageCreateCommand.java
@@ -1,114 +1,114 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class PackageCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public PackageCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getPackage());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Package newElement = UMLFactory.eINSTANCE.createPackage();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Package_2007(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Package 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class PackageCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public PackageCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getPackage());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Package newElement = UMLFactory.eINSTANCE.createPackage();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Package_2007(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Package 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageCreateCommandCN.java
index 186ce5d0d42..6cac8156f39 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageCreateCommandCN.java
@@ -1,114 +1,114 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class PackageCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public PackageCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getPackage());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Package newElement = UMLFactory.eINSTANCE.createPackage();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Package_1012(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Package 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class PackageCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public PackageCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getPackage());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Package newElement = UMLFactory.eINSTANCE.createPackage();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Package_1012(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Package 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageImportCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageImportCreateCommand.java
index 803756fd6bf..6141862ea8b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageImportCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageImportCreateCommand.java
@@ -1,164 +1,169 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PackageImport;
-import org.eclipse.uml2.uml.UMLFactory;
-
-/**
- * @generated
- */
-public class PackageImportCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- protected final EObject source;
-
- /**
- * @generated
- */
- protected final EObject target;
-
- /**
- * @generated
- */
- protected Namespace container;
-
- /**
- * @generated
- */
- public PackageImportCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
- super(request.getLabel(), null, request);
- this.source = source;
- this.target = target;
- container = deduceContainer(source, target);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (source == null && target == null) {
- return false;
- }
- if (source != null && false == source instanceof Namespace) {
- return false;
- }
- if (target != null && false == target instanceof Package) {
- 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreatePackageImport_1065(getContainer(), getSource(), getTarget());
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- if (!canExecute()) {
- throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
- }
- PackageImport newElement = UMLFactory.eINSTANCE.createPackageImport();
- getContainer().getPackageImports().add(newElement);
- newElement.setImportingNamespace(getSource());
- newElement.setImportedPackage(getTarget());
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(PackageImport 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
- */
- @Override
- protected void setElementToEdit(EObject element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected Namespace getSource() {
- return (Namespace) source;
- }
-
- /**
- * @generated
- */
- protected Package getTarget() {
- return (Package) target;
- }
-
- /**
- * @generated
- */
- public Namespace getContainer() {
- return container;
- }
-
- /**
- * Default approach is to traverse ancestors of the source to find instance of container.
- * Modify with appropriate logic.
- *
- * @generated
- */
- protected Namespace 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 Namespace) {
- return (Namespace) element;
- }
- }
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageImport;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * @generated
+ */
+public class PackageImportCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ protected final EObject source;
+
+ /**
+ * @generated
+ */
+ protected final EObject target;
+
+ /**
+ * @generated
+ */
+ protected Namespace container;
+
+ /**
+ * @generated
+ */
+ public PackageImportCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ container = deduceContainer(source, target);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof Namespace) {
+ return false;
+ }
+ if (target != null && false == target instanceof Package) {
+ 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreatePackageImport_1065(getContainer(), getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
+ }
+ PackageImport newElement = UMLFactory.eINSTANCE.createPackageImport();
+ getContainer().getPackageImports()
+ .add(newElement);
+ newElement.setImportingNamespace(
+ getSource()
+ );
+ newElement.setImportedPackage(
+ getTarget()
+ );
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(PackageImport 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
+ */
+ @Override
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Namespace getSource() {
+ return (Namespace) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected Package getTarget() {
+ return (Package) target;
+ }
+
+ /**
+ * @generated
+ */
+ public Namespace getContainer() {
+ return container;
+ }
+
+ /**
+ * Default approach is to traverse ancestors of the source to find instance of container.
+ * Modify with appropriate logic.
+ *
+ * @generated
+ */
+ protected Namespace 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 Namespace) {
+ return (Namespace) element;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageImportReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageImportReorientCommand.java
index 0781687a238..cd570f13c40 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageImportReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PackageImportReorientCommand.java
@@ -1,171 +1,175 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PackageImport;
-
-/**
- * @generated
- */
-public class PackageImportReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public PackageImportReorientCommand(ReorientRelationshipRequest request) {
- super(request.getLabel(), request.getRelationship(), request);
- reorientDirection = request.getDirection();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == getElementToEdit() instanceof PackageImport) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof Namespace && newEnd instanceof Namespace)) {
- return false;
- }
- Package target = getLink().getImportedPackage();
- if (!(getLink().eContainer() instanceof Namespace)) {
- return false;
- }
- Namespace container = (Namespace) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistPackageImport_1065(container, getLink(), getNewSource(), target);
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof Package && newEnd instanceof Package)) {
- return false;
- }
- Namespace source = getLink().getImportingNamespace();
- if (!(getLink().eContainer() instanceof Namespace)) {
- return false;
- }
- Namespace container = (Namespace) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistPackageImport_1065(container, getLink(), source, getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- getLink().setImportingNamespace(getNewSource());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- getLink().setImportedPackage(getNewTarget());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected PackageImport getLink() {
- return (PackageImport) getElementToEdit();
- }
-
- /**
- * @generated
- */
- protected Namespace getOldSource() {
- return (Namespace) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Namespace getNewSource() {
- return (Namespace) newEnd;
- }
-
- /**
- * @generated
- */
- protected Package getOldTarget() {
- return (Package) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Package getNewTarget() {
- return (Package) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageImport;
+
+/**
+ * @generated
+ */
+public class PackageImportReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public PackageImportReorientCommand(ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == getElementToEdit() instanceof PackageImport) {
+ 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 Namespace && newEnd instanceof Namespace)) {
+ return false;
+ }
+ Package target = getLink().getImportedPackage();
+ if (!(getLink().eContainer() instanceof Namespace)) {
+ return false;
+ }
+ Namespace container = (Namespace) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistPackageImport_1065(container, getLink(), getNewSource(), target);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Package && newEnd instanceof Package)) {
+ return false;
+ }
+ Namespace source = getLink().getImportingNamespace();
+ if (!(getLink().eContainer() instanceof Namespace)) {
+ return false;
+ }
+ Namespace container = (Namespace) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistPackageImport_1065(container, getLink(), source, getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().setImportingNamespace(
+ getNewSource()
+ );
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getLink().setImportedPackage(
+ getNewTarget()
+ );
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected PackageImport getLink() {
+ return (PackageImport) getElementToEdit();
+ }
+
+ /**
+ * @generated
+ */
+ protected Namespace getOldSource() {
+ return (Namespace) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Namespace getNewSource() {
+ return (Namespace) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Package getOldTarget() {
+ return (Package) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Package getNewTarget() {
+ return (Package) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PrimitiveTypeCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PrimitiveTypeCreateCommand.java
index a3db2e82ee3..6e2b7c81550 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PrimitiveTypeCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PrimitiveTypeCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PrimitiveType;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class PrimitiveTypeCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public PrimitiveTypeCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getPrimitiveType());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- PrimitiveType newElement = UMLFactory.eINSTANCE.createPrimitiveType();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_PrimitiveType_2009(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(PrimitiveType 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class PrimitiveTypeCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public PrimitiveTypeCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getPrimitiveType());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ PrimitiveType newElement = UMLFactory.eINSTANCE.createPrimitiveType();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_PrimitiveType_2009(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(PrimitiveType 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PrimitiveTypeCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PrimitiveTypeCreateCommandCN.java
index 79ef267a268..f2d1f02bc75 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PrimitiveTypeCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/PrimitiveTypeCreateCommandCN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PrimitiveType;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class PrimitiveTypeCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public PrimitiveTypeCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getPrimitiveType());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- PrimitiveType newElement = UMLFactory.eINSTANCE.createPrimitiveType();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_PrimitiveType_3026(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(PrimitiveType 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class PrimitiveTypeCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public PrimitiveTypeCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getPrimitiveType());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ PrimitiveType newElement = UMLFactory.eINSTANCE.createPrimitiveType();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_PrimitiveType_3026(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(PrimitiveType 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileApplicationCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileApplicationCreateCommand.java
index 71529977bf9..10d93f8b92a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileApplicationCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileApplicationCreateCommand.java
@@ -1,164 +1,169 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.ProfileApplication;
-import org.eclipse.uml2.uml.UMLFactory;
-
-/**
- * @generated
- */
-public class ProfileApplicationCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- protected final EObject source;
-
- /**
- * @generated
- */
- protected final EObject target;
-
- /**
- * @generated
- */
- protected Package container;
-
- /**
- * @generated
- */
- public ProfileApplicationCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
- super(request.getLabel(), null, request);
- this.source = source;
- this.target = target;
- container = deduceContainer(source, target);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (source == null && target == null) {
- return false;
- }
- if (source != null && false == source instanceof Package) {
- return false;
- }
- if (target != null && false == target instanceof Profile) {
- 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateProfileApplication_1045(getContainer(), getSource(), getTarget());
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- if (!canExecute()) {
- throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
- }
- ProfileApplication newElement = UMLFactory.eINSTANCE.createProfileApplication();
- getContainer().getProfileApplications().add(newElement);
- newElement.setApplyingPackage(getSource());
- newElement.setAppliedProfile(getTarget());
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(ProfileApplication 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
- */
- @Override
- protected void setElementToEdit(EObject element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @generated
- */
- protected Package getSource() {
- return (Package) source;
- }
-
- /**
- * @generated
- */
- protected Profile getTarget() {
- return (Profile) target;
- }
-
- /**
- * @generated
- */
- public Package getContainer() {
- return container;
- }
-
- /**
- * Default approach is to traverse ancestors of the source to find instance of container.
- * Modify with appropriate logic.
- *
- * @generated
- */
- protected Package 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 Package) {
- return (Package) element;
- }
- }
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.ProfileApplication;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * @generated
+ */
+public class ProfileApplicationCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ protected final EObject source;
+
+ /**
+ * @generated
+ */
+ protected final EObject target;
+
+ /**
+ * @generated
+ */
+ protected Package container;
+
+ /**
+ * @generated
+ */
+ public ProfileApplicationCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ container = deduceContainer(source, target);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof Package) {
+ return false;
+ }
+ if (target != null && false == target instanceof Profile) {
+ 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 UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateProfileApplication_1045(getContainer(), getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
+ }
+ ProfileApplication newElement = UMLFactory.eINSTANCE.createProfileApplication();
+ getContainer().getProfileApplications()
+ .add(newElement);
+ newElement.setApplyingPackage(
+ getSource()
+ );
+ newElement.setAppliedProfile(
+ getTarget()
+ );
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(ProfileApplication 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
+ */
+ @Override
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Package getSource() {
+ return (Package) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected Profile getTarget() {
+ return (Profile) target;
+ }
+
+ /**
+ * @generated
+ */
+ public Package getContainer() {
+ return container;
+ }
+
+ /**
+ * Default approach is to traverse ancestors of the source to find instance of container.
+ * Modify with appropriate logic.
+ *
+ * @generated
+ */
+ protected Package 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 Package) {
+ return (Package) element;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileApplicationReorientCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileApplicationReorientCommand.java
index 97082ac1a20..dd7d8fce0e8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileApplicationReorientCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileApplicationReorientCommand.java
@@ -1,171 +1,175 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.ProfileApplication;
-
-/**
- * @generated
- */
-public class ProfileApplicationReorientCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private final int reorientDirection;
-
- /**
- * @generated
- */
- private final EObject oldEnd;
-
- /**
- * @generated
- */
- private final EObject newEnd;
-
- /**
- * @generated
- */
- public ProfileApplicationReorientCommand(ReorientRelationshipRequest request) {
- super(request.getLabel(), request.getRelationship(), request);
- reorientDirection = request.getDirection();
- oldEnd = request.getOldRelationshipEnd();
- newEnd = request.getNewRelationshipEnd();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- if (false == getElementToEdit() instanceof ProfileApplication) {
- return false;
- }
- if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- return canReorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return canReorientTarget();
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean canReorientSource() {
- if (!(oldEnd instanceof Package && newEnd instanceof Package)) {
- return false;
- }
- Profile target = getLink().getAppliedProfile();
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistProfileApplication_1045(container, getLink(), getNewSource(), target);
- }
-
- /**
- * @generated
- */
- protected boolean canReorientTarget() {
- if (!(oldEnd instanceof Profile && newEnd instanceof Profile)) {
- return false;
- }
- Package source = getLink().getApplyingPackage();
- if (!(getLink().eContainer() instanceof Package)) {
- return false;
- }
- Package container = (Package) getLink().eContainer();
- return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistProfileApplication_1045(container, getLink(), source, getNewTarget());
- }
-
- /**
- * @generated
- */
- @Override
- 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 == ReorientRequest.REORIENT_SOURCE) {
- return reorientSource();
- }
- if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
- return reorientTarget();
- }
- throw new IllegalStateException();
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientSource() throws ExecutionException {
- getLink().setApplyingPackage(getNewSource());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected CommandResult reorientTarget() throws ExecutionException {
- getLink().setAppliedProfile(getNewTarget());
- return CommandResult.newOKCommandResult(getLink());
- }
-
- /**
- * @generated
- */
- protected ProfileApplication getLink() {
- return (ProfileApplication) getElementToEdit();
- }
-
- /**
- * @generated
- */
- protected Package getOldSource() {
- return (Package) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Package getNewSource() {
- return (Package) newEnd;
- }
-
- /**
- * @generated
- */
- protected Profile getOldTarget() {
- return (Profile) oldEnd;
- }
-
- /**
- * @generated
- */
- protected Profile getNewTarget() {
- return (Profile) newEnd;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.ProfileApplication;
+
+/**
+ * @generated
+ */
+public class ProfileApplicationReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public ProfileApplicationReorientCommand(ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ if (false == getElementToEdit() instanceof ProfileApplication) {
+ 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 Package && newEnd instanceof Package)) {
+ return false;
+ }
+ Profile target = getLink().getAppliedProfile();
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistProfileApplication_1045(container, getLink(), getNewSource(), target);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Profile && newEnd instanceof Profile)) {
+ return false;
+ }
+ Package source = getLink().getApplyingPackage();
+ if (!(getLink().eContainer() instanceof Package)) {
+ return false;
+ }
+ Package container = (Package) getLink().eContainer();
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistProfileApplication_1045(container, getLink(), source, getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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().setApplyingPackage(
+ getNewSource()
+ );
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getLink().setAppliedProfile(
+ getNewTarget()
+ );
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected ProfileApplication getLink() {
+ return (ProfileApplication) getElementToEdit();
+ }
+
+ /**
+ * @generated
+ */
+ protected Package getOldSource() {
+ return (Package) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Package getNewSource() {
+ return (Package) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Profile getOldTarget() {
+ return (Profile) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Profile getNewTarget() {
+ return (Profile) newEnd;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileCreateCommandCN.java
index 14458652aec..1b40f2792a9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileCreateCommandCN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ProfileCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public ProfileCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getProfile());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Profile newElement = UMLFactory.eINSTANCE.createProfile();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Profile_1024(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Profile 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ProfileCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public ProfileCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getProfile());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Profile newElement = UMLFactory.eINSTANCE.createProfile();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Profile_1024(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Profile 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileCreateCommandTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileCreateCommandTN.java
index e7ed778e2f4..e9ccb01d7ee 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileCreateCommandTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ProfileCreateCommandTN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ProfileCreateCommandTN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public ProfileCreateCommandTN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getProfile());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Profile newElement = UMLFactory.eINSTANCE.createProfile();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getPackagedElements().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Profile_1030(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Profile 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ProfileCreateCommandTN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public ProfileCreateCommandTN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getProfile());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Profile newElement = UMLFactory.eINSTANCE.createProfile();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getPackagedElements()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Profile_1030(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Profile 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ShortCutDiagramCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ShortCutDiagramCreateCommand.java
index 078431d91ee..32552a4daf1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ShortCutDiagramCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ShortCutDiagramCreateCommand.java
@@ -1,95 +1,95 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.emf.ecore.resource.Resource;
-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.Diagram;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * @generated
- */
-public class ShortCutDiagramCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- public ShortCutDiagramCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- return true;
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- // Uncomment to put "phantom" objects into the diagram file.
- // org.eclipse.emf.ecore.resource.Resource resource =
- // ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getContainer().eResource();
- // if (resource == null) {
- // return null;
- // }
- Resource resource = getElementToEdit().eResource();
- Diagram newElement = NotationFactory.eINSTANCE.createDiagram();
- resource.getContents().add(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Diagram 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.emf.ecore.resource.Resource;
+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.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class ShortCutDiagramCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ public ShortCutDiagramCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ // Uncomment to put "phantom" objects into the diagram file.
+ // org.eclipse.emf.ecore.resource.Resource resource =
+ // ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getContainer().eResource();
+ // if (resource == null) {
+ // return null;
+ // }
+ Resource resource = getElementToEdit().eResource();
+ Diagram newElement = NotationFactory.eINSTANCE.createDiagram();
+ resource.getContents().add(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Diagram 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/StereotypeCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/StereotypeCreateCommand.java
index c0dbe9ee8f2..6bf8e2f75a8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/StereotypeCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/StereotypeCreateCommand.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class StereotypeCreateCommand extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public StereotypeCreateCommand(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getStereotype());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Stereotype newElement = UMLFactory.eINSTANCE.createStereotype();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getOwnedStereotypes().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Stereotype_1026(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Stereotype 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class StereotypeCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public StereotypeCreateCommand(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getStereotype());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Stereotype newElement = UMLFactory.eINSTANCE.createStereotype();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getOwnedStereotypes()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Stereotype_1026(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Stereotype 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/StereotypeCreateCommandCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/StereotypeCreateCommandCN.java
index 26c7cbd1a06..19bb9ce5b60 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/StereotypeCreateCommandCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/StereotypeCreateCommandCN.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
-import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class StereotypeCreateCommandCN extends EditElementCommand {
-
- /**
- * @generated
- */
- private Diagram diagram = null;
-
- /**
- * @generated
- */
- public StereotypeCreateCommandCN(CreateElementRequest req, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.diagram = diagram;
- }
-
- /**
- * FIXME: replace with setElementToEdit()
- *
- * @generated
- */
- @Override
- protected EObject getElementToEdit() {
- EObject container = ((CreateElementRequest) getRequest()).getContainer();
- if (container instanceof View) {
- container = ((View) container).getElement();
- }
- return container;
- }
-
- /**
- * @generated
- */
- @Override
- public boolean canExecute() {
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getStereotype());
- return data.isPermitted();
- }
-
- /**
- * @generated
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Stereotype newElement = UMLFactory.eINSTANCE.createStereotype();
- EObject target = getElementToEdit();
- ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
- if (data.isPermitted()) {
- if (data.isPathDefined()) {
- if (!data.execute(target, newElement)) {
- return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
- }
- } else {
- Package qualifiedTarget = (Package) target;
- qualifiedTarget.getOwnedStereotypes().add(newElement);
- }
- } else {
- return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
- }
- ElementInitializers.getInstance().init_Stereotype_1023(newElement);
- doConfigure(newElement, monitor, info);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
- return CommandResult.newOKCommandResult(newElement);
- }
-
- /**
- * @generated
- */
- protected void doConfigure(Stereotype 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);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.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.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class StereotypeCreateCommandCN extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private Diagram diagram = null;
+
+ /**
+ * @generated
+ */
+ public StereotypeCreateCommandCN(CreateElementRequest req, Diagram diagram) {
+ super(req.getLabel(), null, req);
+ this.diagram = diagram;
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ *
+ * @generated
+ */
+ @Override
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean canExecute() {
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getStereotype());
+ return data.isPermitted();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Stereotype newElement = UMLFactory.eINSTANCE.createStereotype();
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Package qualifiedTarget = (Package) target;
+ qualifiedTarget.getOwnedStereotypes()
+ .add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+ ElementInitializers.getInstance().init_Stereotype_1023(newElement);
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Stereotype 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/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AppliedStereotypeElementImportEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AppliedStereotypeElementImportEditPart.java
index 1fa1091d4ef..1ee2c463445 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AppliedStereotypeElementImportEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AppliedStereotypeElementImportEditPart.java
@@ -1,767 +1,809 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class AppliedStereotypeElementImportEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6021;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AppliedStereotypeElementImportEditPart.VISUAL_ID), new Point(0, 60));
- }
-
- /**
- * @generated
- */
- public AppliedStereotypeElementImportEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.MIDDLE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.ElementImport_1064, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AppliedStereotypeElementImportEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class AppliedStereotypeElementImportEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6021;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AppliedStereotypeElementImportEditPart.VISUAL_ID), new Point(0, 60));
+ }
+
+ /**
+ * @generated
+ */
+ public AppliedStereotypeElementImportEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.MIDDLE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.ElementImport_1064, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AppliedStereotypeElementImportEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationAppliedStereotypeEditPart.java
index 97ee91ea876..fa75aa278bb 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationAppliedStereotypeEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationAppliedStereotypeEditPart.java
@@ -1,760 +1,802 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class AssociationAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6001;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60));
- }
-
- /**
- * @generated
- */
- public AssociationAppliedStereotypeEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.MIDDLE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationAppliedStereotypeEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- // The label is read-only (defined in GMFGen model)
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class AssociationAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6001;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60));
+ }
+
+ /**
+ * @generated
+ */
+ public AssociationAppliedStereotypeEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.MIDDLE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationAppliedStereotypeEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ // The label is read-only (defined in GMFGen model)
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchEditPart.java
index 4c89346d6d8..9e787e6be0e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchEditPart.java
@@ -1,122 +1,124 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.profile.custom.edit.parts.AbstractAssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.custom.figure.AssociationFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomAssociationBranchItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.AssociationBranchItemSemanticEditPolicy;
-
-/**
- * @generated
- */
-public class AssociationBranchEditPart extends AbstractAssociationBranchEditPart implements ITreeBranchEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 4019;
-
- /**
- * @generated
- */
- public AssociationBranchEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AssociationBranchItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomAssociationBranchItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof AssociationBranchRoleEditPart) {
- ((AssociationBranchRoleEditPart) childEditPart).setLabel(getPrimaryShape().getRoleSourceLabel());
- }
- if (childEditPart instanceof AssociationBranchMultiplicityEditPart) {
- ((AssociationBranchMultiplicityEditPart) childEditPart).setLabel(getPrimaryShape().getMultiplicitySourceLabel());
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof AssociationBranchRoleEditPart) {
- return true;
- }
- if (childEditPart instanceof AssociationBranchMultiplicityEditPart) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * 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
- */
- @Override
- protected Connection createConnectionFigure() {
- return new AssociationFigure();
- }
-
- /**
- * @generated
- */
- @Override
- public AssociationFigure getPrimaryShape() {
- return (AssociationFigure) getFigure();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.profile.custom.edit.parts.AbstractAssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.custom.figure.AssociationFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomAssociationBranchItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.AssociationBranchItemSemanticEditPolicy;
+
+/**
+ * @generated
+ */
+public class AssociationBranchEditPart extends AbstractAssociationBranchEditPart implements ITreeBranchEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 4019;
+
+ /**
+ * @generated
+ */
+ public AssociationBranchEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AssociationBranchItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomAssociationBranchItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof AssociationBranchRoleEditPart) {
+ ((AssociationBranchRoleEditPart) childEditPart).setLabel(
+ getPrimaryShape().getRoleSourceLabel());
+ }
+ if (childEditPart instanceof AssociationBranchMultiplicityEditPart) {
+ ((AssociationBranchMultiplicityEditPart) childEditPart).setLabel(
+ getPrimaryShape().getMultiplicitySourceLabel());
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof AssociationBranchRoleEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof AssociationBranchMultiplicityEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ protected Connection createConnectionFigure() {
+ return new AssociationFigure();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public AssociationFigure getPrimaryShape() {
+ return (AssociationFigure) getFigure();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchMultiplicityEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchMultiplicityEditPart.java
index be41818fff1..6c99adb7011 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchMultiplicityEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchMultiplicityEditPart.java
@@ -1,762 +1,804 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndTargetMultiplicityEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class AssociationBranchMultiplicityEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6035;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchMultiplicityEditPart.VISUAL_ID), new Point(0, 20));
- }
-
- /**
- * @generated
- */
- public AssociationBranchMultiplicityEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndTargetMultiplicityEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.SOURCE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Association_4019, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchMultiplicityEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- // The label is read-only (defined in GMFGen model)
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndTargetMultiplicityEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class AssociationBranchMultiplicityEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6035;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchMultiplicityEditPart.VISUAL_ID), new Point(0, 20));
+ }
+
+ /**
+ * @generated
+ */
+ public AssociationBranchMultiplicityEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndTargetMultiplicityEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.SOURCE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Association_4019, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchMultiplicityEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ // The label is read-only (defined in GMFGen model)
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchRoleEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchRoleEditPart.java
index 1e74334f035..d95a0f6ac8e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchRoleEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationBranchRoleEditPart.java
@@ -1,762 +1,804 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndTargetEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class AssociationBranchRoleEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6024;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchRoleEditPart.VISUAL_ID), new Point(0, -20));
- }
-
- /**
- * @generated
- */
- public AssociationBranchRoleEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndTargetEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.SOURCE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Association_4019, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchRoleEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- // The label is read-only (defined in GMFGen model)
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndTargetEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class AssociationBranchRoleEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6024;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchRoleEditPart.VISUAL_ID), new Point(0, -20));
+ }
+
+ /**
+ * @generated
+ */
+ public AssociationBranchRoleEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndTargetEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.SOURCE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Association_4019, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchRoleEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ // The label is read-only (defined in GMFGen model)
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationEditPart.java
index 96309f0c4c2..4af85649195 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationEditPart.java
@@ -1,149 +1,155 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.edit.parts.AbstractAssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.custom.figure.AssociationFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomAssociationItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.AssociationItemSemanticEditPolicy;
-
-/**
- * @generated
- */
-public class AssociationEditPart extends AbstractAssociationEditPart implements ITreeBranchEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 4001;
-
- /**
- * @generated
- */
- public AssociationEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AssociationItemSemanticEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomAssociationItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof AssociationAppliedStereotypeEditPart) {
- ((AssociationAppliedStereotypeEditPart) childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel());
- }
- if (childEditPart instanceof AssociationNameEditPart) {
- ((AssociationNameEditPart) childEditPart).setLabel(getPrimaryShape().getAssociationNameLabel());
- }
- if (childEditPart instanceof AssociationRoleTargetEditPart) {
- ((AssociationRoleTargetEditPart) childEditPart).setLabel(getPrimaryShape().getRoleTargetLabel());
- }
- if (childEditPart instanceof AssociationRoleSourceEditPart) {
- ((AssociationRoleSourceEditPart) childEditPart).setLabel(getPrimaryShape().getRoleSourceLabel());
- }
- if (childEditPart instanceof AssociationMultiplicitySourceEditPart) {
- ((AssociationMultiplicitySourceEditPart) childEditPart).setLabel(getPrimaryShape().getMultiplicitySourceLabel());
- }
- if (childEditPart instanceof AssociationMultiplicityTargetEditPart) {
- ((AssociationMultiplicityTargetEditPart) childEditPart).setLabel(getPrimaryShape().getMultiplicityTargetLabel());
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof AssociationAppliedStereotypeEditPart) {
- return true;
- }
- if (childEditPart instanceof AssociationNameEditPart) {
- return true;
- }
- if (childEditPart instanceof AssociationRoleTargetEditPart) {
- return true;
- }
- if (childEditPart instanceof AssociationRoleSourceEditPart) {
- return true;
- }
- if (childEditPart instanceof AssociationMultiplicitySourceEditPart) {
- return true;
- }
- if (childEditPart instanceof AssociationMultiplicityTargetEditPart) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * 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
- */
- @Override
- protected Connection createConnectionFigure() {
- return new AssociationFigure();
- }
-
- /**
- * @generated
- */
- @Override
- public AssociationFigure getPrimaryShape() {
- return (AssociationFigure) getFigure();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.edit.parts.AbstractAssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.custom.figure.AssociationFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomAssociationItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.AssociationItemSemanticEditPolicy;
+
+/**
+ * @generated
+ */
+public class AssociationEditPart extends AbstractAssociationEditPart implements ITreeBranchEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 4001;
+
+ /**
+ * @generated
+ */
+ public AssociationEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AssociationItemSemanticEditPolicy());
+ installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomAssociationItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof AssociationAppliedStereotypeEditPart) {
+ ((AssociationAppliedStereotypeEditPart) childEditPart).setLabel(
+ getPrimaryShape().getAppliedStereotypeLabel());
+ }
+ if (childEditPart instanceof AssociationNameEditPart) {
+ ((AssociationNameEditPart) childEditPart).setLabel(
+ getPrimaryShape().getAssociationNameLabel());
+ }
+ if (childEditPart instanceof AssociationRoleTargetEditPart) {
+ ((AssociationRoleTargetEditPart) childEditPart).setLabel(
+ getPrimaryShape().getRoleTargetLabel());
+ }
+ if (childEditPart instanceof AssociationRoleSourceEditPart) {
+ ((AssociationRoleSourceEditPart) childEditPart).setLabel(
+ getPrimaryShape().getRoleSourceLabel());
+ }
+ if (childEditPart instanceof AssociationMultiplicitySourceEditPart) {
+ ((AssociationMultiplicitySourceEditPart) childEditPart).setLabel(
+ getPrimaryShape().getMultiplicitySourceLabel());
+ }
+ if (childEditPart instanceof AssociationMultiplicityTargetEditPart) {
+ ((AssociationMultiplicityTargetEditPart) childEditPart).setLabel(
+ getPrimaryShape().getMultiplicityTargetLabel());
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof AssociationAppliedStereotypeEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof AssociationNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof AssociationRoleTargetEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof AssociationRoleSourceEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof AssociationMultiplicitySourceEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof AssociationMultiplicityTargetEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ protected Connection createConnectionFigure() {
+ return new AssociationFigure();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public AssociationFigure getPrimaryShape() {
+ return (AssociationFigure) getFigure();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationMultiplicitySourceEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationMultiplicitySourceEditPart.java
index 2e318fca054..db750e00fbc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationMultiplicitySourceEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationMultiplicitySourceEditPart.java
@@ -1,769 +1,811 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndSourceMultiplicityEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class AssociationMultiplicitySourceEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6033;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicitySourceEditPart.VISUAL_ID), new Point(0, 20));
- }
-
- /**
- * @generated
- */
- public AssociationMultiplicitySourceEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndSourceMultiplicityEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.TARGET;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicitySourceEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndSourceMultiplicityEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class AssociationMultiplicitySourceEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6033;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicitySourceEditPart.VISUAL_ID), new Point(0, 20));
+ }
+
+ /**
+ * @generated
+ */
+ public AssociationMultiplicitySourceEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndSourceMultiplicityEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.TARGET;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicitySourceEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationMultiplicityTargetEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationMultiplicityTargetEditPart.java
index 85da925e4fd..2c74414626a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationMultiplicityTargetEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationMultiplicityTargetEditPart.java
@@ -1,769 +1,811 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndTargetMultiplicityEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class AssociationMultiplicityTargetEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6034;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicityTargetEditPart.VISUAL_ID), new Point(0, -20));
- }
-
- /**
- * @generated
- */
- public AssociationMultiplicityTargetEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndTargetMultiplicityEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.SOURCE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicityTargetEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndTargetMultiplicityEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class AssociationMultiplicityTargetEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6034;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicityTargetEditPart.VISUAL_ID), new Point(0, -20));
+ }
+
+ /**
+ * @generated
+ */
+ public AssociationMultiplicityTargetEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndTargetMultiplicityEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.SOURCE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicityTargetEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationNameEditPart.java
index a2727f3d167..b652cf0495d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationNameEditPart.java
@@ -1,767 +1,809 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class AssociationNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6002;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNameEditPart.VISUAL_ID), new Point(0, 20));
- }
-
- /**
- * @generated
- */
- public AssociationNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.MIDDLE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class AssociationNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6002;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNameEditPart.VISUAL_ID), new Point(0, 20));
+ }
+
+ /**
+ * @generated
+ */
+ public AssociationNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.MIDDLE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationNodeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationNodeEditPart.java
index a6e4fc7c365..fbe68717948 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationNodeEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationNodeEditPart.java
@@ -1,195 +1,192 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-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.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-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.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.DiamondNode;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomAssociationNodeItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.AssociationNodeItemSemanticEditPolicy;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class AssociationNodeEditPart extends NodeEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2015;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public AssociationNodeEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AssociationNodeItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomAssociationNodeItemSemanticEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new DiamondNode();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.DiamondNode
- *
- * @generated
- */
- @Override
- public DiamondNode getPrimaryShape() {
- return (DiamondNode) primaryShape;
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(20, 20);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- protected IFigure setupContentPane(IFigure nodeShape) {
- return nodeShape; // use nodeShape itself as contentPane
- }
-
- /**
- * @generated
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+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.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+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.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.DiamondNode;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomAssociationNodeItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.AssociationNodeItemSemanticEditPolicy;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class AssociationNodeEditPart extends NodeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2015;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public AssociationNodeEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AssociationNodeItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomAssociationNodeItemSemanticEditPolicy());
+ // 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
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new DiamondNode();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.DiamondNode
+ *
+ * @generated
+ */
+ @Override
+ public DiamondNode getPrimaryShape() {
+ return (DiamondNode) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(20, 20);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ protected IFigure setupContentPane(IFigure nodeShape) {
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationRoleSourceEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationRoleSourceEditPart.java
index 0cfb420ac40..47e110b78db 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationRoleSourceEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationRoleSourceEditPart.java
@@ -1,762 +1,804 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndSourceEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class AssociationRoleSourceEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6005;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleSourceEditPart.VISUAL_ID), new Point(0, -20));
- }
-
- /**
- * @generated
- */
- public AssociationRoleSourceEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndSourceEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.TARGET;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleSourceEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- // The label is read-only (defined in GMFGen model)
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndSourceEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class AssociationRoleSourceEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6005;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleSourceEditPart.VISUAL_ID), new Point(0, -20));
+ }
+
+ /**
+ * @generated
+ */
+ public AssociationRoleSourceEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndSourceEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.TARGET;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleSourceEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ // The label is read-only (defined in GMFGen model)
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationRoleTargetEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationRoleTargetEditPart.java
index d775c994358..9aa4c05b657 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationRoleTargetEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/AssociationRoleTargetEditPart.java
@@ -1,762 +1,804 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndTargetEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class AssociationRoleTargetEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6003;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleTargetEditPart.VISUAL_ID), new Point(0, 20));
- }
-
- /**
- * @generated
- */
- public AssociationRoleTargetEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndTargetEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.SOURCE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleTargetEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- // The label is read-only (defined in GMFGen model)
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndTargetEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class AssociationRoleTargetEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6003;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleTargetEditPart.VISUAL_ID), new Point(0, 20));
+ }
+
+ /**
+ * @generated
+ */
+ public AssociationRoleTargetEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new DisplayAssociationEndTargetEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.SOURCE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Association_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleTargetEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ // The label is read-only (defined in GMFGen model)
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassAttributeCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassAttributeCompartmentEditPart.java
index add1ca00df0..8b7da80c164 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassAttributeCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassAttributeCompartmentEditPart.java
@@ -1,135 +1,141 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassAttributeCompartmentItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class ClassAttributeCompartmentEditPart extends ListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 7017;
-
- /**
- * @generated
- */
- public ClassAttributeCompartmentEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.ClassAttributeCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassAttributeCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassAttributeCompartmentItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class ClassAttributeCompartmentEditPart extends ListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 7017;
+
+ /**
+ * @generated
+ */
+ public ClassAttributeCompartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.ClassAttributeCompartmentEditPart_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassAttributeCompartmentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassAttributeCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassAttributeCompartmentEditPartCN.java
index 3569293b576..a6bc3edd625 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassAttributeCompartmentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassAttributeCompartmentEditPartCN.java
@@ -1,135 +1,141 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassAttributeCompartmentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class ClassAttributeCompartmentEditPartCN extends ListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 7011;
-
- /**
- * @generated
- */
- public ClassAttributeCompartmentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.ClassAttributeCompartmentEditPartCN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassAttributeCompartmentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassAttributeCompartmentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class ClassAttributeCompartmentEditPartCN extends ListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 7011;
+
+ /**
+ * @generated
+ */
+ public ClassAttributeCompartmentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.ClassAttributeCompartmentEditPartCN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassAttributeCompartmentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassEditPart.java
index 3985443f67e..26ba888641e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassEditPart.java
@@ -1,323 +1,321 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomClassItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClasseItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class ClassEditPart extends NodeEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2008;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public ClassEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClasseItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomClassItemSemanticEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new ClassifierFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure
- *
- * @generated
- */
- @Override
- public ClassifierFigure getPrimaryShape() {
- return (ClassifierFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ClassNameEditPart) {
- ((ClassNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof ClassOperationCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((ClassOperationCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof ClassAttributeCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((ClassAttributeCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ClassNameEditPart) {
- return true;
- }
- if (childEditPart instanceof ClassOperationCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- pane.remove(((ClassOperationCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof ClassAttributeCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- pane.remove(((ClassAttributeCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof ClassOperationCompartmentEditPart) {
- return getPrimaryShape().getOperationCompartmentFigure();
- }
- if (editPart instanceof ClassAttributeCompartmentEditPart) {
- return getPrimaryShape().getAttributeCompartmentFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassNameEditPart.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- if (request instanceof CreateViewAndElementRequest) {
- CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
- IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
- if (type == UMLElementTypes.Operation_3020) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassOperationCompartmentEditPart.VISUAL_ID));
- }
- if (type == UMLElementTypes.Property_3002) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassAttributeCompartmentEditPart.VISUAL_ID));
- }
- }
- return super.getTargetEditPart(request);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomClassItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClasseItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ClassEditPart extends NodeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2008;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ClassEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClasseItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomClassItemSemanticEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new ClassFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure
+ *
+ * @generated
+ */
+ @Override
+ public ClassFigure getPrimaryShape() {
+ return (ClassFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ClassNameEditPart) {
+ ((ClassNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof ClassOperationCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((ClassOperationCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof ClassAttributeCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((ClassAttributeCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ClassNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof ClassOperationCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ pane.remove(((ClassOperationCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof ClassAttributeCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ pane.remove(((ClassAttributeCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof ClassOperationCompartmentEditPart) {
+ return getPrimaryShape().getOperationCompartmentFigure();
+ }
+ if (editPart instanceof ClassAttributeCompartmentEditPart) {
+ return getPrimaryShape().getAttributeCompartmentFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassNameEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ if (request instanceof CreateViewAndElementRequest) {
+ CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
+ IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
+ if (type == UMLElementTypes.Operation_3020) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassOperationCompartmentEditPart.VISUAL_ID));
+ }
+ if (type == UMLElementTypes.Property_3002) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassAttributeCompartmentEditPart.VISUAL_ID));
+ }
+ }
+ return super.getTargetEditPart(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassEditPartCN.java
index c252d5a9008..bf2e9b04431 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassEditPartCN.java
@@ -1,320 +1,318 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomClassItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class ClassEditPartCN extends NodeEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3010;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public ClassEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomClassItemSemanticEditPolicyCN());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new ClassifierFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure
- *
- * @generated
- */
- @Override
- public ClassifierFigure getPrimaryShape() {
- return (ClassifierFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ClassNameEditPartCN) {
- ((ClassNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof ClassAttributeCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((ClassAttributeCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof ClassOperationCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((ClassOperationCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ClassNameEditPartCN) {
- return true;
- }
- if (childEditPart instanceof ClassAttributeCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- pane.remove(((ClassAttributeCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof ClassOperationCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- pane.remove(((ClassOperationCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof ClassAttributeCompartmentEditPartCN) {
- return getPrimaryShape().getAttributeCompartmentFigure();
- }
- if (editPart instanceof ClassOperationCompartmentEditPartCN) {
- return getPrimaryShape().getOperationCompartmentFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassNameEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- if (request instanceof CreateViewAndElementRequest) {
- CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
- IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
- if (type == UMLElementTypes.Property_3002) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassAttributeCompartmentEditPartCN.VISUAL_ID));
- }
- if (type == UMLElementTypes.Operation_3020) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassOperationCompartmentEditPartCN.VISUAL_ID));
- }
- }
- return super.getTargetEditPart(request);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomClassItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ClassEditPartCN extends NodeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3010;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ClassEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomClassItemSemanticEditPolicyCN());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new ClassFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure
+ *
+ * @generated
+ */
+ @Override
+ public ClassFigure getPrimaryShape() {
+ return (ClassFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ClassNameEditPartCN) {
+ ((ClassNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof ClassAttributeCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((ClassAttributeCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof ClassOperationCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((ClassOperationCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ClassNameEditPartCN) {
+ return true;
+ }
+ if (childEditPart instanceof ClassAttributeCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ pane.remove(((ClassAttributeCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof ClassOperationCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ pane.remove(((ClassOperationCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof ClassAttributeCompartmentEditPartCN) {
+ return getPrimaryShape().getAttributeCompartmentFigure();
+ }
+ if (editPart instanceof ClassOperationCompartmentEditPartCN) {
+ return getPrimaryShape().getOperationCompartmentFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassNameEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ if (request instanceof CreateViewAndElementRequest) {
+ CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
+ IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
+ if (type == UMLElementTypes.Property_3002) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassAttributeCompartmentEditPartCN.VISUAL_ID));
+ }
+ if (type == UMLElementTypes.Operation_3020) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ClassOperationCompartmentEditPartCN.VISUAL_ID));
+ }
+ }
+ return super.getTargetEditPart(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassNameEditPart.java
index 42f9adb675a..aaddbdf07b5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassNameEditPart.java
@@ -1,826 +1,867 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
-import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ClassNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5029;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ClassNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @generated
- */
- protected EObject getParserElement() {
- return resolveSemanticElement();
- }
-
- /**
- * @generated
- */
- protected Image getLabelIcon() {
- EObject parserElement = getParserElement();
- if (parserElement == null) {
- return null;
- }
- List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer());
- for (View view : views) {
- if (AppearanceHelper.showElementIcon(view)) {
- return UMLElementTypes.getImage(parserElement.eClass());
- }
- }
- 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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Class_2008, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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();
- }
- }
- }
- if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation) event.getNewValue()).getSource())) {
- refreshLabel();
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
+import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ClassNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5029;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ClassNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer());
+ for (View view : views) {
+ if (AppearanceHelper.showElementIcon(view)) {
+ return UMLElementTypes.getImage(parserElement.eClass());
+ }
+ }
+ 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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Class_2008, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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();
+ }
+ }
+ }
+ if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation) event.getNewValue()).getSource())) {
+ refreshLabel();
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassNameEditPartCN.java
index adec632c0b1..9cacb5e8a63 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassNameEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ClassNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5014;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ClassNameEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Class_3010, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassNameEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ClassNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5014;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ClassNameEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Class_3010, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassNameEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationCompartmentEditPart.java
index b0ddc40ad12..80a3744be5f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationCompartmentEditPart.java
@@ -1,135 +1,141 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassOperationCompartmentItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class ClassOperationCompartmentEditPart extends ListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 7018;
-
- /**
- * @generated
- */
- public ClassOperationCompartmentEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.ClassOperationCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassOperationCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassOperationCompartmentItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class ClassOperationCompartmentEditPart extends ListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 7018;
+
+ /**
+ * @generated
+ */
+ public ClassOperationCompartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.ClassOperationCompartmentEditPart_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassOperationCompartmentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationCompartmentEditPartCN.java
index 914554441ab..5202422d992 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationCompartmentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationCompartmentEditPartCN.java
@@ -1,135 +1,141 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassOperationCompartmentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class ClassOperationCompartmentEditPartCN extends ListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 7012;
-
- /**
- * @generated
- */
- public ClassOperationCompartmentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.ClassOperationCompartmentEditPartCN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassOperationCompartmentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassOperationCompartmentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class ClassOperationCompartmentEditPartCN extends ListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 7012;
+
+ /**
+ * @generated
+ */
+ public ClassOperationCompartmentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.ClassOperationCompartmentEditPartCN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassOperationCompartmentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationEditPart.java
index ff04e5b4b18..8e03b3d7bc8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassOperationEditPart.java
@@ -1,815 +1,856 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.requests.SelectionRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-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.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.IPrimaryEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
-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.DragEditPartsTrackerEx;
-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.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.OperationLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.AppliedStereotypeOperationDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassOperationItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextNonResizableEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ClassOperationEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3020;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ClassOperationEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public DragTracker getDragTracker(Request request) {
- if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) {
- return null;
- }
- return new DragEditPartsTrackerEx(this);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassOperationItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new UMLTextNonResizableEditPolicy());
- installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(AbstractAppliedStereotypeDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeOperationDisplayEditPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new OperationLabelEditPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Operation_3020, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- 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();
- }
- }
- }
- if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
- refreshUnderline();
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createFigure() {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim() {
- return new WrappingLabel();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isSelectable() {
- return getFigure().isShowing();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.DragTracker;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.requests.SelectionRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+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.IPrimaryEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
+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.DragEditPartsTrackerEx;
+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.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.OperationLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.AppliedStereotypeOperationDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassOperationItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextNonResizableEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ClassOperationEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3020;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ClassOperationEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public DragTracker getDragTracker(Request request) {
+ if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) {
+ return null;
+ }
+ return new DragEditPartsTrackerEx(this);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassOperationItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new UMLTextNonResizableEditPolicy());
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(AbstractAppliedStereotypeDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeOperationDisplayEditPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new OperationLabelEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Operation_3020, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+ }
+ }
+ if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
+ refreshUnderline();
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createFigure() {
+ IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isSelectable() {
+ return getFigure().isShowing();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassPropertyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassPropertyEditPart.java
index bc245974a9c..cea7b7da6e8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassPropertyEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ClassPropertyEditPart.java
@@ -1,815 +1,856 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.requests.SelectionRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-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.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.IPrimaryEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
-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.DragEditPartsTrackerEx;
-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.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PropertyLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.AppliedStereotypePropertyDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassPropertyItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextNonResizableEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class ClassPropertyEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3002;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ClassPropertyEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public DragTracker getDragTracker(Request request) {
- if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) {
- return null;
- }
- return new DragEditPartsTrackerEx(this);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassPropertyItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new UMLTextNonResizableEditPolicy());
- installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(AbstractAppliedStereotypeDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypePropertyDisplayEditPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new PropertyLabelEditPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Property_3002, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- 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();
- }
- }
- }
- if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
- refreshUnderline();
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createFigure() {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim() {
- return new WrappingLabel();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isSelectable() {
- return getFigure().isShowing();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.DragTracker;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.requests.SelectionRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+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.IPrimaryEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
+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.DragEditPartsTrackerEx;
+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.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PropertyLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.AppliedStereotypePropertyDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ClassPropertyItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextNonResizableEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class ClassPropertyEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3002;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ClassPropertyEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public DragTracker getDragTracker(Request request) {
+ if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) {
+ return null;
+ }
+ return new DragEditPartsTrackerEx(this);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ClassPropertyItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new UMLTextNonResizableEditPolicy());
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(AbstractAppliedStereotypeDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypePropertyDisplayEditPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new PropertyLabelEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Property_3002, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+ }
+ }
+ if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
+ refreshUnderline();
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createFigure() {
+ IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isSelectable() {
+ return getFigure().isShowing();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentBodyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentBodyEditPart.java
index f2b491779e4..7c2c9403660 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentBodyEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentBodyEditPart.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public CommentBodyEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Comment_1002, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentBodyEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public CommentBodyEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Comment_1002, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentBodyEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentBodyEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentBodyEditPartCN.java
index c56d141f11c..b6bd8f3f07c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentBodyEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentBodyEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1008;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public CommentBodyEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Comment_1007, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentBodyEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1008;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public CommentBodyEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Comment_1007, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentBodyEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentEditPart.java
index 88ad586c658..dd58fd53eee 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentEditPart.java
@@ -1,274 +1,271 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractCommentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.HTMLCornerBentFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.CommentEditPartItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class CommentEditPart extends AbstractCommentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1002;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public CommentEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CommentEditPartItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new HTMLCornerBentFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.HTMLCornerBentFigure
- *
- * @generated
- */
- @Override
- public HTMLCornerBentFigure getPrimaryShape() {
- return (HTMLCornerBentFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof CommentBodyEditPart) {
- ((CommentBodyEditPart) childEditPart).setLabel(getPrimaryShape().getCornerBentFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof CommentBodyEditPart) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(CommentBodyEditPart.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractCommentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.HTMLCornerBentFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.CommentEditPartItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class CommentEditPart extends AbstractCommentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1002;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public CommentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CommentEditPartItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new HTMLCornerBentFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.HTMLCornerBentFigure
+ *
+ * @generated
+ */
+ @Override
+ public HTMLCornerBentFigure getPrimaryShape() {
+ return (HTMLCornerBentFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof CommentBodyEditPart) {
+ ((CommentBodyEditPart) childEditPart).setLabel(getPrimaryShape().getCornerBentFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof CommentBodyEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(CommentBodyEditPart.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentEditPartCN.java
index fe6eca3c066..5c587e14a0d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/CommentEditPartCN.java
@@ -1,274 +1,271 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractCommentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.HTMLCornerBentFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.CommentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class CommentEditPartCN extends AbstractCommentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1007;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public CommentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CommentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new HTMLCornerBentFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.HTMLCornerBentFigure
- *
- * @generated
- */
- @Override
- public HTMLCornerBentFigure getPrimaryShape() {
- return (HTMLCornerBentFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof CommentBodyEditPartCN) {
- ((CommentBodyEditPartCN) childEditPart).setLabel(getPrimaryShape().getCornerBentFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof CommentBodyEditPartCN) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(CommentBodyEditPartCN.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractCommentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.HTMLCornerBentFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.CommentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class CommentEditPartCN extends AbstractCommentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1007;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public CommentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CommentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new HTMLCornerBentFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.HTMLCornerBentFigure
+ *
+ * @generated
+ */
+ @Override
+ public HTMLCornerBentFigure getPrimaryShape() {
+ return (HTMLCornerBentFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof CommentBodyEditPartCN) {
+ ((CommentBodyEditPartCN) childEditPart).setLabel(getPrimaryShape().getCornerBentFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof CommentBodyEditPartCN) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(CommentBodyEditPartCN.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintBodyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintBodyEditPart.java
index bdf604fa550..5ed39b7c96e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintBodyEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintBodyEditPart.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5063;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ConstraintBodyEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Constraint_1014, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintBodyEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5063;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ConstraintBodyEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Constraint_1014, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintBodyEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintBodyEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintBodyEditPartCN.java
index b35bc1ab5b2..5d497b3f660 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintBodyEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintBodyEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ConstraintBodyEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5064;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ConstraintBodyEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Constraint_1028, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintBodyEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ConstraintBodyEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5064;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ConstraintBodyEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Constraint_1028, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintBodyEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintEditPart.java
index afc04d36169..787defa1a2d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintEditPart.java
@@ -1,282 +1,279 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ConstraintFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ConstraintItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class ConstraintEditPart extends AbstractConstraintEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1014;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public ConstraintEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ConstraintItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new ConstraintFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.ConstraintFigure
- *
- * @generated
- */
- @Override
- public ConstraintFigure getPrimaryShape() {
- return (ConstraintFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ConstraintNameEditPart) {
- ((ConstraintNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof ConstraintBodyEditPart) {
- ((ConstraintBodyEditPart) childEditPart).setLabel(getPrimaryShape().getConstraintFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ConstraintNameEditPart) {
- return true;
- }
- if (childEditPart instanceof ConstraintBodyEditPart) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ConstraintNameEditPart.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractConstraintEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ConstraintFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ConstraintItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ConstraintEditPart extends AbstractConstraintEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1014;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ConstraintEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ConstraintItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new ConstraintFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.ConstraintFigure
+ *
+ * @generated
+ */
+ @Override
+ public ConstraintFigure getPrimaryShape() {
+ return (ConstraintFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ConstraintNameEditPart) {
+ ((ConstraintNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof ConstraintBodyEditPart) {
+ ((ConstraintBodyEditPart) childEditPart).setLabel(getPrimaryShape().getConstraintFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ConstraintNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof ConstraintBodyEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ConstraintNameEditPart.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintEditPartCN.java
index 8f821d23c4b..4acd8042226 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintEditPartCN.java
@@ -1,278 +1,275 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ConstraintFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ConstraintItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class ConstraintEditPartCN extends AbstractConstraintEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1028;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public ConstraintEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ConstraintItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new ConstraintFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.ConstraintFigure
- *
- * @generated
- */
- @Override
- public ConstraintFigure getPrimaryShape() {
- return (ConstraintFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ConstraintNameEditPartCN) {
- ((ConstraintNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof ConstraintBodyEditPartCN) {
- ((ConstraintBodyEditPartCN) childEditPart).setLabel(getPrimaryShape().getConstraintFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ConstraintNameEditPartCN) {
- return true;
- }
- if (childEditPart instanceof ConstraintBodyEditPartCN) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ConstraintNameEditPartCN.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractConstraintEditPart;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ConstraintFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ConstraintItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ConstraintEditPartCN extends AbstractConstraintEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1028;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ConstraintEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ConstraintItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new ConstraintFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.ConstraintFigure
+ *
+ * @generated
+ */
+ @Override
+ public ConstraintFigure getPrimaryShape() {
+ return (ConstraintFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ConstraintNameEditPartCN) {
+ ((ConstraintNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof ConstraintBodyEditPartCN) {
+ ((ConstraintBodyEditPartCN) childEditPart).setLabel(getPrimaryShape().getConstraintFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ConstraintNameEditPartCN) {
+ return true;
+ }
+ if (childEditPart instanceof ConstraintBodyEditPartCN) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ConstraintNameEditPartCN.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPart.java
index 52ff505ed1b..7298718449b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPart.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1015;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ConstraintNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Constraint_1014, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1015;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ConstraintNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Constraint_1014, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPartCN.java
index a8565ce970a..04ef4489b0f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1059;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ConstraintNameEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Constraint_1028, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintNameEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1059;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ConstraintNameEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Constraint_1028, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintNameEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeAttributeCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeAttributeCompartmentEditPart.java
index c79a85159c7..6faf2f6499c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeAttributeCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeAttributeCompartmentEditPart.java
@@ -1,136 +1,142 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeAttributeCompartmentItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class DataTypeAttributeCompartmentEditPart extends ResizeableListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1067;
-
- /**
- * @generated
- */
- public DataTypeAttributeCompartmentEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.DataTypeAttributeCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeAttributeCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeAttributeCompartmentItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class DataTypeAttributeCompartmentEditPart extends ResizeableListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1067;
+
+ /**
+ * @generated
+ */
+ public DataTypeAttributeCompartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.DataTypeAttributeCompartmentEditPart_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeAttributeCompartmentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeAttributeCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeAttributeCompartmentEditPartCN.java
index e0647289fc5..d966311ad81 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeAttributeCompartmentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeAttributeCompartmentEditPartCN.java
@@ -1,136 +1,142 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeAttributeCompartmentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class DataTypeAttributeCompartmentEditPartCN extends ResizeableListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1069;
-
- /**
- * @generated
- */
- public DataTypeAttributeCompartmentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.DataTypeAttributeCompartmentEditPartCN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeAttributeCompartmentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeAttributeCompartmentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class DataTypeAttributeCompartmentEditPartCN extends ResizeableListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1069;
+
+ /**
+ * @generated
+ */
+ public DataTypeAttributeCompartmentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.DataTypeAttributeCompartmentEditPartCN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeAttributeCompartmentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeEditPart.java
index ec23eb61f84..6e4ff917138 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeEditPart.java
@@ -1,334 +1,331 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.DataTypeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomDataTypeItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class DataTypeEditPart extends ClassifierEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2010;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public DataTypeEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDataTypeItemSemanticEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new DataTypeFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.DataTypeFigure
- *
- * @generated
- */
- @Override
- public DataTypeFigure getPrimaryShape() {
- return (DataTypeFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof DataTypeNameEditPart) {
- ((DataTypeNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof DataTypeAttributeCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((DataTypeAttributeCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof DataTypeOperationCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((DataTypeOperationCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof DataTypeNameEditPart) {
- return true;
- }
- if (childEditPart instanceof DataTypeAttributeCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- pane.remove(((DataTypeAttributeCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof DataTypeOperationCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- pane.remove(((DataTypeOperationCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof DataTypeAttributeCompartmentEditPart) {
- return getPrimaryShape().getAttributeCompartmentFigure();
- }
- if (editPart instanceof DataTypeOperationCompartmentEditPart) {
- return getPrimaryShape().getOperationCompartmentFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeNameEditPart.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- if (request instanceof CreateViewAndElementRequest) {
- CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
- IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
- if (type == UMLElementTypes.Property_3018) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeAttributeCompartmentEditPart.VISUAL_ID));
- }
- if (type == UMLElementTypes.Operation_3019) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeOperationCompartmentEditPart.VISUAL_ID));
- }
- }
- return super.getTargetEditPart(request);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.DataTypeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomDataTypeItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class DataTypeEditPart extends ClassifierEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2010;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public DataTypeEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDataTypeItemSemanticEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new DataTypeFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.DataTypeFigure
+ *
+ * @generated
+ */
+ @Override
+ public DataTypeFigure getPrimaryShape() {
+ return (DataTypeFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof DataTypeNameEditPart) {
+ ((DataTypeNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof DataTypeAttributeCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((DataTypeAttributeCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof DataTypeOperationCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((DataTypeOperationCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof DataTypeNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof DataTypeAttributeCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ pane.remove(((DataTypeAttributeCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof DataTypeOperationCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ pane.remove(((DataTypeOperationCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof DataTypeAttributeCompartmentEditPart) {
+ return getPrimaryShape().getAttributeCompartmentFigure();
+ }
+ if (editPart instanceof DataTypeOperationCompartmentEditPart) {
+ return getPrimaryShape().getOperationCompartmentFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeNameEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ if (request instanceof CreateViewAndElementRequest) {
+ CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
+ IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
+ if (type == UMLElementTypes.Property_3018) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeAttributeCompartmentEditPart.VISUAL_ID));
+ }
+ if (type == UMLElementTypes.Operation_3019) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeOperationCompartmentEditPart.VISUAL_ID));
+ }
+ }
+ return super.getTargetEditPart(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeEditPartCN.java
index c338785c013..c35e3de4c0d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeEditPartCN.java
@@ -1,331 +1,328 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.DataTypeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomDataTypeItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class DataTypeEditPartCN extends ClassifierEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3027;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public DataTypeEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDataTypeItemSemanticEditPolicyCN());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new DataTypeFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.DataTypeFigure
- *
- * @generated
- */
- @Override
- public DataTypeFigure getPrimaryShape() {
- return (DataTypeFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof DataTypeNameEditPartCN) {
- ((DataTypeNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof DataTypeAttributeCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((DataTypeAttributeCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof DataTypeOperationCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((DataTypeOperationCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof DataTypeNameEditPartCN) {
- return true;
- }
- if (childEditPart instanceof DataTypeAttributeCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- pane.remove(((DataTypeAttributeCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof DataTypeOperationCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- pane.remove(((DataTypeOperationCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof DataTypeAttributeCompartmentEditPartCN) {
- return getPrimaryShape().getAttributeCompartmentFigure();
- }
- if (editPart instanceof DataTypeOperationCompartmentEditPartCN) {
- return getPrimaryShape().getOperationCompartmentFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeNameEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- if (request instanceof CreateViewAndElementRequest) {
- CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
- IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
- if (type == UMLElementTypes.Property_3018) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeAttributeCompartmentEditPartCN.VISUAL_ID));
- }
- if (type == UMLElementTypes.Operation_3019) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeOperationCompartmentEditPartCN.VISUAL_ID));
- }
- }
- return super.getTargetEditPart(request);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.DataTypeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomDataTypeItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class DataTypeEditPartCN extends ClassifierEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3027;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public DataTypeEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDataTypeItemSemanticEditPolicyCN());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new DataTypeFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.DataTypeFigure
+ *
+ * @generated
+ */
+ @Override
+ public DataTypeFigure getPrimaryShape() {
+ return (DataTypeFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof DataTypeNameEditPartCN) {
+ ((DataTypeNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof DataTypeAttributeCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((DataTypeAttributeCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof DataTypeOperationCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((DataTypeOperationCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof DataTypeNameEditPartCN) {
+ return true;
+ }
+ if (childEditPart instanceof DataTypeAttributeCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ pane.remove(((DataTypeAttributeCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof DataTypeOperationCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ pane.remove(((DataTypeOperationCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof DataTypeAttributeCompartmentEditPartCN) {
+ return getPrimaryShape().getAttributeCompartmentFigure();
+ }
+ if (editPart instanceof DataTypeOperationCompartmentEditPartCN) {
+ return getPrimaryShape().getOperationCompartmentFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeNameEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ if (request instanceof CreateViewAndElementRequest) {
+ CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
+ IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
+ if (type == UMLElementTypes.Property_3018) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeAttributeCompartmentEditPartCN.VISUAL_ID));
+ }
+ if (type == UMLElementTypes.Operation_3019) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(DataTypeOperationCompartmentEditPartCN.VISUAL_ID));
+ }
+ }
+ return super.getTargetEditPart(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeNameEditPart.java
index 8e10a4fff9d..9f8112fad5a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeNameEditPart.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class DataTypeNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5035;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public DataTypeNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.DataType_2010, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class DataTypeNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5035;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public DataTypeNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.DataType_2010, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeNameEditPartCN.java
index b02d03bc0b5..53c06bdf67d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeNameEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class DataTypeNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5061;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public DataTypeNameEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.DataType_3027, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeNameEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class DataTypeNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5061;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public DataTypeNameEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.DataType_3027, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeNameEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationCompartmentEditPart.java
index 9f743130c85..14705b89dab 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationCompartmentEditPart.java
@@ -1,136 +1,142 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeOperationCompartmentItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class DataTypeOperationCompartmentEditPart extends ResizeableListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1068;
-
- /**
- * @generated
- */
- public DataTypeOperationCompartmentEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.DataTypeOperationCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeOperationCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeOperationCompartmentItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class DataTypeOperationCompartmentEditPart extends ResizeableListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1068;
+
+ /**
+ * @generated
+ */
+ public DataTypeOperationCompartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.DataTypeOperationCompartmentEditPart_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeOperationCompartmentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationCompartmentEditPartCN.java
index 92591ce434f..3a8cdd7dc5b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationCompartmentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationCompartmentEditPartCN.java
@@ -1,136 +1,142 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeOperationCompartmentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class DataTypeOperationCompartmentEditPartCN extends ResizeableListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1070;
-
- /**
- * @generated
- */
- public DataTypeOperationCompartmentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.DataTypeOperationCompartmentEditPartCN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeOperationCompartmentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeOperationCompartmentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class DataTypeOperationCompartmentEditPartCN extends ResizeableListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1070;
+
+ /**
+ * @generated
+ */
+ public DataTypeOperationCompartmentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.DataTypeOperationCompartmentEditPartCN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeOperationCompartmentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationEditPart.java
index 41044d5064b..8914ddb58b6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypeOperationEditPart.java
@@ -1,815 +1,856 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.requests.SelectionRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-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.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.IPrimaryEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
-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.DragEditPartsTrackerEx;
-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.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.OperationLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.AppliedStereotypeOperationDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeOperationItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextNonResizableEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class DataTypeOperationEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3019;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public DataTypeOperationEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public DragTracker getDragTracker(Request request) {
- if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) {
- return null;
- }
- return new DragEditPartsTrackerEx(this);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeOperationItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new UMLTextNonResizableEditPolicy());
- installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(AbstractAppliedStereotypeDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeOperationDisplayEditPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new OperationLabelEditPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Operation_3019, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- 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();
- }
- }
- }
- if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
- refreshUnderline();
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createFigure() {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim() {
- return new WrappingLabel();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isSelectable() {
- return getFigure().isShowing();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.DragTracker;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.requests.SelectionRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+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.IPrimaryEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
+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.DragEditPartsTrackerEx;
+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.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.OperationLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.AppliedStereotypeOperationDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeOperationItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextNonResizableEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class DataTypeOperationEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3019;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public DataTypeOperationEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public DragTracker getDragTracker(Request request) {
+ if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) {
+ return null;
+ }
+ return new DragEditPartsTrackerEx(this);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypeOperationItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new UMLTextNonResizableEditPolicy());
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(AbstractAppliedStereotypeDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeOperationDisplayEditPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new OperationLabelEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Operation_3019, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+ }
+ }
+ if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
+ refreshUnderline();
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createFigure() {
+ IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isSelectable() {
+ return getFigure().isShowing();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypePropertyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypePropertyEditPart.java
index d8280771df3..eeb0e16ef7a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypePropertyEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DataTypePropertyEditPart.java
@@ -1,815 +1,856 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.requests.SelectionRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-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.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.IPrimaryEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
-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.DragEditPartsTrackerEx;
-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.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PropertyLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.AppliedStereotypePropertyDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypePropertyItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextNonResizableEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class DataTypePropertyEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3018;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public DataTypePropertyEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public DragTracker getDragTracker(Request request) {
- if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) {
- return null;
- }
- return new DragEditPartsTrackerEx(this);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypePropertyItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new UMLTextNonResizableEditPolicy());
- installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(AbstractAppliedStereotypeDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypePropertyDisplayEditPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new PropertyLabelEditPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Property_3018, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- 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();
- }
- }
- }
- if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
- refreshUnderline();
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createFigure() {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim() {
- return new WrappingLabel();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isSelectable() {
- return getFigure().isShowing();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.DragTracker;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.requests.SelectionRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+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.IPrimaryEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
+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.DragEditPartsTrackerEx;
+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.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PropertyLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.AppliedStereotypePropertyDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypePropertyItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextNonResizableEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class DataTypePropertyEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3018;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public DataTypePropertyEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public DragTracker getDragTracker(Request request) {
+ if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) {
+ return null;
+ }
+ return new DragEditPartsTrackerEx(this);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DataTypePropertyItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new UMLTextNonResizableEditPolicy());
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(AbstractAppliedStereotypeDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypePropertyDisplayEditPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new PropertyLabelEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Property_3018, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+ }
+ }
+ if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
+ refreshUnderline();
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createFigure() {
+ IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isSelectable() {
+ return getFigure().isShowing();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyAppliedStereotypeEditPart.java
index e053e3cb5d5..16abb32e9cc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyAppliedStereotypeEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyAppliedStereotypeEditPart.java
@@ -1,760 +1,802 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6027;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60));
- }
-
- /**
- * @generated
- */
- public DependencyAppliedStereotypeEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.MIDDLE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Dependency_4008, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyAppliedStereotypeEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- // The label is read-only (defined in GMFGen model)
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6027;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60));
+ }
+
+ /**
+ * @generated
+ */
+ public DependencyAppliedStereotypeEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.MIDDLE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Dependency_4008, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyAppliedStereotypeEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ // The label is read-only (defined in GMFGen model)
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyEditPart.java
index acaaa44b6e9..835ba5be5ad 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyEditPart.java
@@ -1,123 +1,125 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.edge.DashedEdgeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DependencyItemSemanticEditPolicy;
-
-/**
- * @generated
- */
-public class DependencyEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 4008;
-
- /**
- * @generated
- */
- public DependencyEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DependencyItemSemanticEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof DependencyNameEditPart) {
- ((DependencyNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- }
- if (childEditPart instanceof DependencyAppliedStereotypeEditPart) {
- ((DependencyAppliedStereotypeEditPart) childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel());
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof DependencyNameEditPart) {
- return true;
- }
- if (childEditPart instanceof DependencyAppliedStereotypeEditPart) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * 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
- */
- @Override
- protected Connection createConnectionFigure() {
- return new DashedEdgeFigure();
- }
-
- /**
- * @generated
- */
- @Override
- public DashedEdgeFigure getPrimaryShape() {
- return (DashedEdgeFigure) getFigure();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.edge.DashedEdgeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DependencyItemSemanticEditPolicy;
+
+/**
+ * @generated
+ */
+public class DependencyEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 4008;
+
+ /**
+ * @generated
+ */
+ public DependencyEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DependencyItemSemanticEditPolicy());
+ installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof DependencyNameEditPart) {
+ ((DependencyNameEditPart) childEditPart).setLabel(
+ getPrimaryShape().getNameLabel());
+ }
+ if (childEditPart instanceof DependencyAppliedStereotypeEditPart) {
+ ((DependencyAppliedStereotypeEditPart) childEditPart).setLabel(
+ getPrimaryShape().getAppliedStereotypeLabel());
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof DependencyNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof DependencyAppliedStereotypeEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ protected Connection createConnectionFigure() {
+ return new DashedEdgeFigure();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public DashedEdgeFigure getPrimaryShape() {
+ return (DashedEdgeFigure) getFigure();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyNameEditPart.java
index e4cbf4df2db..be36fc54a44 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyNameEditPart.java
@@ -1,767 +1,809 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6026;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNameEditPart.VISUAL_ID), new Point(0, 40));
- }
-
- /**
- * @generated
- */
- public DependencyNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.MIDDLE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Dependency_4008, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6026;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNameEditPart.VISUAL_ID), new Point(0, 40));
+ }
+
+ /**
+ * @generated
+ */
+ public DependencyNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.MIDDLE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Dependency_4008, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyNodeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyNodeEditPart.java
index 33af209f203..144678dbdea 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyNodeEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DependencyNodeEditPart.java
@@ -1,239 +1,237 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-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.runtime.diagram.ui.editparts.IBorderItemEditPart;
-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.gef.ui.figures.DefaultSizeNodeFigure;
-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.DependencyNodeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DependencyNodeItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class DependencyNodeEditPart extends NodeEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2014;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public DependencyNodeEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DependencyNodeItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- View childView = (View) child.getModel();
- switch (UMLVisualIDRegistry.getVisualID(childView)) {
- case MultiDependencyLabelEditPart.VISUAL_ID:
- return new BorderItemSelectionEditPolicy() {
-
- @Override
- 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;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new DependencyNodeFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.DependencyNodeFigure
- *
- * @generated
- */
- @Override
- public DependencyNodeFigure getPrimaryShape() {
- return (DependencyNodeFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
- if (borderItemEditPart instanceof MultiDependencyLabelEditPart) {
- BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
- locator.setBorderItemOffset(new Dimension(-20, -20));
- borderItemContainer.add(borderItemEditPart.getFigure(), locator);
- } else {
- super.addBorderItem(borderItemContainer, borderItemEditPart);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(10, 10);
- 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
- */
- @Override
- protected NodeFigure createMainFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- protected IFigure setupContentPane(IFigure nodeShape) {
- return nodeShape; // use nodeShape itself as contentPane
- }
-
- /**
- * @generated
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(MultiDependencyLabelEditPart.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+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.runtime.diagram.ui.editparts.IBorderItemEditPart;
+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.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.DependencyNodeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DependencyNodeItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class DependencyNodeEditPart extends NodeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2014;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public DependencyNodeEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DependencyNodeItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ // 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 (UMLVisualIDRegistry.getVisualID(childView)) {
+ case MultiDependencyLabelEditPart.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
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new DependencyNodeFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.DependencyNodeFigure
+ *
+ * @generated
+ */
+ @Override
+ public DependencyNodeFigure getPrimaryShape() {
+ return (DependencyNodeFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
+ if (borderItemEditPart instanceof MultiDependencyLabelEditPart) {
+ BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
+ locator.setBorderItemOffset(new Dimension(-20, -20));
+ borderItemContainer.add(borderItemEditPart.getFigure(), locator);
+ } else
+ {
+ super.addBorderItem(borderItemContainer, borderItemEditPart);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(10, 10);
+ 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
+ */
+ @Override
+ protected NodeFigure createMainFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ protected IFigure setupContentPane(IFigure nodeShape) {
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(MultiDependencyLabelEditPart.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DiagramNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DiagramNameEditPart.java
index f2bf449c379..bf862e8354b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DiagramNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/DiagramNameEditPart.java
@@ -1,806 +1,847 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.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.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class DiagramNameEditPart extends LabelEditPart implements ITextAwareEditPart, IBorderItemEditPart, ILabelRoleProvider {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DiagramNameEditPart.VISUAL_ID), new Point(0, 0));
- }
-
- /**
- * @generated
- */
- public DiagramNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- }
-
- /**
- * @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
- */
- @Override
- 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 if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Diagram_2016, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DiagramNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim() {
- return new WrappingLabel();
- }
-
- /**
- * @generated
- */
- public String getLabelRole() {
- return "Name";//$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- public String getIconPathRole() {
- return "platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/label_role/name.png";//$NON-NLS-1$
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class DiagramNameEditPart extends LabelEditPart implements ITextAwareEditPart, IBorderItemEditPart, ILabelRoleProvider {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DiagramNameEditPart.VISUAL_ID), new Point(0, 0));
+ }
+
+ /**
+ * @generated
+ */
+ public DiagramNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ }
+
+ /**
+ * @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
+ */
+ @Override
+ 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 if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Diagram_2016, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.DiagramNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+
+ /**
+ * @generated
+ */
+ public String getLabelRole() {
+ return "Name";//$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ public String getIconPathRole() {
+ return "platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/label_role/name.png";//$NON-NLS-1$
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java
index b26434c7783..8f1823ea8bc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java
@@ -1,767 +1,809 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6020;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportAliasEditPart.VISUAL_ID), new Point(0, 40));
- }
-
- /**
- * @generated
- */
- public ElementImportAliasEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.MIDDLE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.ElementImport_1064, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportAliasEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6020;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportAliasEditPart.VISUAL_ID), new Point(0, 40));
+ }
+
+ /**
+ * @generated
+ */
+ public ElementImportAliasEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.MIDDLE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.ElementImport_1064, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportAliasEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportEditPart.java
index 3b1078d2266..85f2ba68bec 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportEditPart.java
@@ -1,123 +1,125 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.edge.DashedEdgeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.AppliedStereotypeElementImportLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ElementImportItemSemanticEditPolicy;
-
-/**
- * @generated
- */
-public class ElementImportEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1064;
-
- /**
- * @generated
- */
- public ElementImportEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ElementImportItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeElementImportLabelDisplayEditPolicy());
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ElementImportAliasEditPart) {
- ((ElementImportAliasEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- }
- if (childEditPart instanceof AppliedStereotypeElementImportEditPart) {
- ((AppliedStereotypeElementImportEditPart) childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel());
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ElementImportAliasEditPart) {
- return true;
- }
- if (childEditPart instanceof AppliedStereotypeElementImportEditPart) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * 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
- */
- @Override
- protected Connection createConnectionFigure() {
- return new DashedEdgeFigure();
- }
-
- /**
- * @generated
- */
- @Override
- public DashedEdgeFigure getPrimaryShape() {
- return (DashedEdgeFigure) getFigure();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.edge.DashedEdgeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.AppliedStereotypeElementImportLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ElementImportItemSemanticEditPolicy;
+
+/**
+ * @generated
+ */
+public class ElementImportEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1064;
+
+ /**
+ * @generated
+ */
+ public ElementImportEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ElementImportItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeElementImportLabelDisplayEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ElementImportAliasEditPart) {
+ ((ElementImportAliasEditPart) childEditPart).setLabel(
+ getPrimaryShape().getNameLabel());
+ }
+ if (childEditPart instanceof AppliedStereotypeElementImportEditPart) {
+ ((AppliedStereotypeElementImportEditPart) childEditPart).setLabel(
+ getPrimaryShape().getAppliedStereotypeLabel());
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ElementImportAliasEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof AppliedStereotypeElementImportEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ protected Connection createConnectionFigure() {
+ return new DashedEdgeFigure();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public DashedEdgeFigure getPrimaryShape() {
+ return (DashedEdgeFigure) getFigure();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEditPart.java
index e158a25c167..eb6fc579b4e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEditPart.java
@@ -1,317 +1,314 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.EnumerationFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomEnumerationItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.EnumerationItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class EnumerationEditPart extends ClassifierEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2006;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public EnumerationEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EnumerationItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomEnumerationItemSemanticEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new EnumerationFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.EnumerationFigure
- *
- * @generated
- */
- @Override
- public EnumerationFigure getPrimaryShape() {
- return (EnumerationFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof EnumerationNameEditPart) {
- ((EnumerationNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof EnumerationEnumerationLiteralCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getEnumerationLiteralCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((EnumerationEnumerationLiteralCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof EnumerationNameEditPart) {
- return true;
- }
- if (childEditPart instanceof EnumerationEnumerationLiteralCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getEnumerationLiteralCompartmentFigure();
- pane.remove(((EnumerationEnumerationLiteralCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof EnumerationEnumerationLiteralCompartmentEditPart) {
- return getPrimaryShape().getEnumerationLiteralCompartmentFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(EnumerationNameEditPart.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- if (request instanceof CreateViewAndElementRequest) {
- CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
- IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
- if (type == UMLElementTypes.EnumerationLiteral_1037) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID));
- }
- }
- return super.getTargetEditPart(request);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.EnumerationFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomEnumerationItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.EnumerationItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class EnumerationEditPart extends ClassifierEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2006;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public EnumerationEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EnumerationItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomEnumerationItemSemanticEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new EnumerationFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.EnumerationFigure
+ *
+ * @generated
+ */
+ @Override
+ public EnumerationFigure getPrimaryShape() {
+ return (EnumerationFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof EnumerationNameEditPart) {
+ ((EnumerationNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof EnumerationEnumerationLiteralCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getEnumerationLiteralCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((EnumerationEnumerationLiteralCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof EnumerationNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof EnumerationEnumerationLiteralCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getEnumerationLiteralCompartmentFigure();
+ pane.remove(((EnumerationEnumerationLiteralCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof EnumerationEnumerationLiteralCompartmentEditPart) {
+ return getPrimaryShape().getEnumerationLiteralCompartmentFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(EnumerationNameEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ if (request instanceof CreateViewAndElementRequest) {
+ CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
+ IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
+ if (type == UMLElementTypes.EnumerationLiteral_1037) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID));
+ }
+ }
+ return super.getTargetEditPart(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEditPartCN.java
index 81eb687f43d..a0f56159d38 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEditPartCN.java
@@ -1,315 +1,312 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.EnumerationFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomEnumerationItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.EnumerationItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class EnumerationEditPartCN extends ClassifierEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3025;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public EnumerationEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EnumerationItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomEnumerationItemSemanticEditPolicyCN());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new EnumerationFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.EnumerationFigure
- *
- * @generated
- */
- @Override
- public EnumerationFigure getPrimaryShape() {
- return (EnumerationFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof EnumerationNameEditPartCN) {
- ((EnumerationNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof EnumerationEnumerationLiteralCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getEnumerationLiteralCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((EnumerationEnumerationLiteralCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof EnumerationNameEditPartCN) {
- return true;
- }
- if (childEditPart instanceof EnumerationEnumerationLiteralCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getEnumerationLiteralCompartmentFigure();
- pane.remove(((EnumerationEnumerationLiteralCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof EnumerationEnumerationLiteralCompartmentEditPartCN) {
- return getPrimaryShape().getEnumerationLiteralCompartmentFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(EnumerationNameEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- if (request instanceof CreateViewAndElementRequest) {
- CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
- IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
- if (type == UMLElementTypes.EnumerationLiteral_1037) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID));
- }
- }
- return super.getTargetEditPart(request);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.EnumerationFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomEnumerationItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.EnumerationItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class EnumerationEditPartCN extends ClassifierEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3025;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public EnumerationEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EnumerationItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomEnumerationItemSemanticEditPolicyCN());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new EnumerationFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.EnumerationFigure
+ *
+ * @generated
+ */
+ @Override
+ public EnumerationFigure getPrimaryShape() {
+ return (EnumerationFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof EnumerationNameEditPartCN) {
+ ((EnumerationNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof EnumerationEnumerationLiteralCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getEnumerationLiteralCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((EnumerationEnumerationLiteralCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof EnumerationNameEditPartCN) {
+ return true;
+ }
+ if (childEditPart instanceof EnumerationEnumerationLiteralCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getEnumerationLiteralCompartmentFigure();
+ pane.remove(((EnumerationEnumerationLiteralCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof EnumerationEnumerationLiteralCompartmentEditPartCN) {
+ return getPrimaryShape().getEnumerationLiteralCompartmentFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(EnumerationNameEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ if (request instanceof CreateViewAndElementRequest) {
+ CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
+ IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
+ if (type == UMLElementTypes.EnumerationLiteral_1037) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID));
+ }
+ }
+ return super.getTargetEditPart(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEnumerationLiteralCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEnumerationLiteralCompartmentEditPart.java
index cfb1f64a7b6..aa92d13f758 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEnumerationLiteralCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEnumerationLiteralCompartmentEditPart.java
@@ -1,136 +1,142 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.EnumerationEnumerationLiteralCompartmentItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class EnumerationEnumerationLiteralCompartmentEditPart extends ResizeableListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1063;
-
- /**
- * @generated
- */
- public EnumerationEnumerationLiteralCompartmentEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.EnumerationEnumerationLiteralCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EnumerationEnumerationLiteralCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.EnumerationEnumerationLiteralCompartmentItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class EnumerationEnumerationLiteralCompartmentEditPart extends ResizeableListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1063;
+
+ /**
+ * @generated
+ */
+ public EnumerationEnumerationLiteralCompartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.EnumerationEnumerationLiteralCompartmentEditPart_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EnumerationEnumerationLiteralCompartmentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEnumerationLiteralCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEnumerationLiteralCompartmentEditPartCN.java
index 5ca5e609902..7a52b245b44 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEnumerationLiteralCompartmentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationEnumerationLiteralCompartmentEditPartCN.java
@@ -1,136 +1,142 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.EnumerationEnumerationLiteralCompartmentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class EnumerationEnumerationLiteralCompartmentEditPartCN extends ResizeableListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1062;
-
- /**
- * @generated
- */
- public EnumerationEnumerationLiteralCompartmentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.EnumerationEnumerationLiteralCompartmentEditPartCN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EnumerationEnumerationLiteralCompartmentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.EnumerationEnumerationLiteralCompartmentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class EnumerationEnumerationLiteralCompartmentEditPartCN extends ResizeableListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1062;
+
+ /**
+ * @generated
+ */
+ public EnumerationEnumerationLiteralCompartmentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.EnumerationEnumerationLiteralCompartmentEditPartCN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EnumerationEnumerationLiteralCompartmentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationLiteralEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationLiteralEditPart.java
index 096372aa0d5..1ffdb5da627 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationLiteralEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationLiteralEditPart.java
@@ -1,810 +1,851 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.requests.SelectionRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-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.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.IPrimaryEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
-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.DragEditPartsTrackerEx;
-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.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.EnumerationLiteralItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextNonResizableEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class EnumerationLiteralEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1037;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public EnumerationLiteralEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public DragTracker getDragTracker(Request request) {
- if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) {
- return null;
- }
- return new DragEditPartsTrackerEx(this);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EnumerationLiteralItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new UMLTextNonResizableEditPolicy());
- installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.EnumerationLiteral_1037, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- 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();
- }
- }
- }
- if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
- refreshUnderline();
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createFigure() {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim() {
- return new WrappingLabel();
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isSelectable() {
- return getFigure().isShowing();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.DragTracker;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.requests.SelectionRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+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.IPrimaryEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
+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.DragEditPartsTrackerEx;
+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.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.EnumerationLiteralItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextNonResizableEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class EnumerationLiteralEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1037;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public EnumerationLiteralEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public DragTracker getDragTracker(Request request) {
+ if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) {
+ return null;
+ }
+ return new DragEditPartsTrackerEx(this);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EnumerationLiteralItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new UMLTextNonResizableEditPolicy());
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.EnumerationLiteral_1037, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+ }
+ }
+ if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
+ refreshUnderline();
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createFigure() {
+ IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isSelectable() {
+ return getFigure().isShowing();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationNameEditPart.java
index 865e6fc3de2..f37cf04f5c2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationNameEditPart.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class EnumerationNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5023;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public EnumerationNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Enumeration_2006, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class EnumerationNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5023;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public EnumerationNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Enumeration_2006, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationNameEditPartCN.java
index 7309dedaf4f..e26f4c06ca7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/EnumerationNameEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class EnumerationNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5055;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public EnumerationNameEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Enumeration_3025, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationNameEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class EnumerationNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5055;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public EnumerationNameEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Enumeration_3025, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationNameEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/GeneralizationAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/GeneralizationAppliedStereotypeEditPart.java
index 20f38e01d12..179c934fef5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/GeneralizationAppliedStereotypeEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/GeneralizationAppliedStereotypeEditPart.java
@@ -1,760 +1,802 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6007;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60));
- }
-
- /**
- * @generated
- */
- public GeneralizationAppliedStereotypeEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.MIDDLE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Generalization_4002, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationAppliedStereotypeEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- // The label is read-only (defined in GMFGen model)
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6007;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60));
+ }
+
+ /**
+ * @generated
+ */
+ public GeneralizationAppliedStereotypeEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.MIDDLE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Generalization_4002, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationAppliedStereotypeEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ // The label is read-only (defined in GMFGen model)
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/GeneralizationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/GeneralizationEditPart.java
index 59b94efe3fd..9b626d2522c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/GeneralizationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/GeneralizationEditPart.java
@@ -1,119 +1,120 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.edge.GeneralizationFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomGeneralizationItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.GeneralizationItemSemanticEditPolicy;
-
-/**
- * @generated
- */
-public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 4002;
-
- /**
- * @generated
- */
- public GeneralizationEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new GeneralizationItemSemanticEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomGeneralizationItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof GeneralizationAppliedStereotypeEditPart) {
- ((GeneralizationAppliedStereotypeEditPart) childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel());
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof GeneralizationAppliedStereotypeEditPart) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * 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
- */
- @Override
- protected Connection createConnectionFigure() {
- return new GeneralizationFigure();
- }
-
- /**
- * @generated
- */
- @Override
- public GeneralizationFigure getPrimaryShape() {
- return (GeneralizationFigure) getFigure();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.edge.GeneralizationFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomGeneralizationItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.GeneralizationItemSemanticEditPolicy;
+
+/**
+ * @generated
+ */
+public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 4002;
+
+ /**
+ * @generated
+ */
+ public GeneralizationEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new GeneralizationItemSemanticEditPolicy());
+ installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomGeneralizationItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof GeneralizationAppliedStereotypeEditPart) {
+ ((GeneralizationAppliedStereotypeEditPart) childEditPart).setLabel(
+ getPrimaryShape().getAppliedStereotypeLabel());
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof GeneralizationAppliedStereotypeEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ protected Connection createConnectionFigure() {
+ return new GeneralizationFigure();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public GeneralizationFigure getPrimaryShape() {
+ return (GeneralizationFigure) getFigure();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassEditPart.java
index d69d6fafb9c..310f872fa1d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassEditPart.java
@@ -1,286 +1,285 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomMetaclassItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.MetaclassItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class MetaclassEditPart extends ClassifierEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1031;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public MetaclassEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new MetaclassItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomMetaclassItemSemanticEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- // set the figure active when the feature of the of a class is true
- if (resolveSemanticElement() != null) {
- if (resolveSemanticElement().equals(event.getNotifier()) && (event.getFeature() instanceof EAttribute) && ((EAttribute) (event.getFeature())).getName().equals("isActive")) {
- ((ClassifierFigure) getFigure()).setActive(event.getNewBooleanValue());
- refreshVisuals();
- }
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new ClassifierFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure
- *
- * @generated
- */
- @Override
- public ClassifierFigure getPrimaryShape() {
- return (ClassifierFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof MetaclassNameEditPart) {
- ((MetaclassNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof MetaclassNameEditPart) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(MetaclassNameEditPart.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAttribute;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomMetaclassItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.MetaclassItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class MetaclassEditPart extends ClassEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1031;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public MetaclassEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new MetaclassItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomMetaclassItemSemanticEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ //set the figure active when the feature of the of a class is true
+ if (resolveSemanticElement() != null) {
+ if (resolveSemanticElement().equals(event.getNotifier()) && (event.getFeature() instanceof EAttribute) && ((EAttribute) (event.getFeature())).getName().equals("isActive")) {
+ ((ClassFigure) getFigure()).setActive(event.getNewBooleanValue());
+ refreshVisuals();
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new ClassFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure
+ *
+ * @generated
+ */
+ @Override
+ public ClassFigure getPrimaryShape() {
+ return (ClassFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof MetaclassNameEditPart) {
+ ((MetaclassNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof MetaclassNameEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(MetaclassNameEditPart.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassEditPartCN.java
index ee4674a300f..e9b0afa286d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassEditPartCN.java
@@ -1,286 +1,285 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomMetaclassItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.MetaclassItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class MetaclassEditPartCN extends ClassifierEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3028;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public MetaclassEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new MetaclassItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomMetaclassItemSemanticEditPolicyCN());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- // set the figure active when the feature of the of a class is true
- if (resolveSemanticElement() != null) {
- if (resolveSemanticElement().equals(event.getNotifier()) && (event.getFeature() instanceof EAttribute) && ((EAttribute) (event.getFeature())).getName().equals("isActive")) {
- ((ClassifierFigure) getFigure()).setActive(event.getNewBooleanValue());
- refreshVisuals();
- }
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new ClassifierFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure
- *
- * @generated
- */
- @Override
- public ClassifierFigure getPrimaryShape() {
- return (ClassifierFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof MetaclassNameEditPartCN) {
- ((MetaclassNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof MetaclassNameEditPartCN) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(MetaclassNameEditPartCN.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAttribute;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomMetaclassItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.MetaclassItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class MetaclassEditPartCN extends ClassEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3028;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public MetaclassEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new MetaclassItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomMetaclassItemSemanticEditPolicyCN());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ //set the figure active when the feature of the of a class is true
+ if (resolveSemanticElement() != null) {
+ if (resolveSemanticElement().equals(event.getNotifier()) && (event.getFeature() instanceof EAttribute) && ((EAttribute) (event.getFeature())).getName().equals("isActive")) {
+ ((ClassFigure) getFigure()).setActive(event.getNewBooleanValue());
+ refreshVisuals();
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new ClassFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure
+ *
+ * @generated
+ */
+ @Override
+ public ClassFigure getPrimaryShape() {
+ return (ClassFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof MetaclassNameEditPartCN) {
+ ((MetaclassNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof MetaclassNameEditPartCN) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(MetaclassNameEditPartCN.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassNameEditPart.java
index 55a5edac309..f1b793d752f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassNameEditPart.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class MetaclassNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1084;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public MetaclassNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Class_1031, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class MetaclassNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1084;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public MetaclassNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Class_1031, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassNameEditPartCN.java
index 79136518185..9dca7cb06bb 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MetaclassNameEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class MetaclassNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5062;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public MetaclassNameEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Class_3028, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassNameEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class MetaclassNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5062;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public MetaclassNameEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Class_3028, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassNameEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelEditPartCN.java
index 5f2b01ed879..d7e5b55b20f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelEditPartCN.java
@@ -1,294 +1,291 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ModelItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class ModelEditPartCN extends NamedElementEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1027;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public ModelEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ModelItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new PackageFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure
- *
- * @generated
- */
- @Override
- public PackageFigure getPrimaryShape() {
- return (PackageFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ModelNameEditPartCN) {
- ((ModelNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof ModelPackageableElementCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((ModelPackageableElementCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ModelNameEditPartCN) {
- return true;
- }
- if (childEditPart instanceof ModelPackageableElementCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- pane.remove(((ModelPackageableElementCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof ModelPackageableElementCompartmentEditPartCN) {
- return getPrimaryShape().getPackageableElementFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ModelNameEditPartCN.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ModelItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ModelEditPartCN extends NamedElementEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1027;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ModelEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ModelItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new PackageFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure
+ *
+ * @generated
+ */
+ @Override
+ public PackageFigure getPrimaryShape() {
+ return (PackageFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ModelNameEditPartCN) {
+ ((ModelNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof ModelPackageableElementCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((ModelPackageableElementCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ModelNameEditPartCN) {
+ return true;
+ }
+ if (childEditPart instanceof ModelPackageableElementCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ pane.remove(((ModelPackageableElementCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof ModelPackageableElementCompartmentEditPartCN) {
+ return getPrimaryShape().getPackageableElementFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ModelNameEditPartCN.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelEditPartTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelEditPartTN.java
index 647c00eb79f..06b0bcd7400 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelEditPartTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelEditPartTN.java
@@ -1,294 +1,291 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ModelItemSemanticEditPolicyTN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class ModelEditPartTN extends NamedElementEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2005;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public ModelEditPartTN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ModelItemSemanticEditPolicyTN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new PackageFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure
- *
- * @generated
- */
- @Override
- public PackageFigure getPrimaryShape() {
- return (PackageFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ModelNameEditPart) {
- ((ModelNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof ModelPackageableElementCompartmentEditPartTN) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((ModelPackageableElementCompartmentEditPartTN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ModelNameEditPart) {
- return true;
- }
- if (childEditPart instanceof ModelPackageableElementCompartmentEditPartTN) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- pane.remove(((ModelPackageableElementCompartmentEditPartTN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof ModelPackageableElementCompartmentEditPartTN) {
- return getPrimaryShape().getPackageableElementFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(200, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ModelNameEditPart.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ModelItemSemanticEditPolicyTN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ModelEditPartTN extends NamedElementEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2005;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ModelEditPartTN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ModelItemSemanticEditPolicyTN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new PackageFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure
+ *
+ * @generated
+ */
+ @Override
+ public PackageFigure getPrimaryShape() {
+ return (PackageFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ModelNameEditPart) {
+ ((ModelNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof ModelPackageableElementCompartmentEditPartTN) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((ModelPackageableElementCompartmentEditPartTN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ModelNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof ModelPackageableElementCompartmentEditPartTN) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ pane.remove(((ModelPackageableElementCompartmentEditPartTN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof ModelPackageableElementCompartmentEditPartTN) {
+ return getPrimaryShape().getPackageableElementFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(200, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ModelNameEditPart.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelNameEditPart.java
index b6b6970d99c..07d23f62f13 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelNameEditPart.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5020;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ModelNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Model_2005, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5020;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ModelNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Model_2005, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelNameEditPartCN.java
index 34cc2f41cb7..b24613d995d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelNameEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1056;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ModelNameEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Model_1027, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelNameEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1056;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ModelNameEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Model_1027, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelNameEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelPackageableElementCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelPackageableElementCompartmentEditPartCN.java
index 4b7e073013b..4979daef935 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelPackageableElementCompartmentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelPackageableElementCompartmentEditPartCN.java
@@ -1,129 +1,135 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ModelPackageableElementCompartmentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class ModelPackageableElementCompartmentEditPartCN extends ShapeCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1058;
-
- /**
- * @generated
- */
- public ModelPackageableElementCompartmentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.ModelPackageableElementCompartmentEditPartCN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ModelPackageableElementCompartmentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ModelPackageableElementCompartmentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class ModelPackageableElementCompartmentEditPartCN extends ShapeCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1058;
+
+ /**
+ * @generated
+ */
+ public ModelPackageableElementCompartmentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.ModelPackageableElementCompartmentEditPartCN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ModelPackageableElementCompartmentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelPackageableElementCompartmentEditPartTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelPackageableElementCompartmentEditPartTN.java
index 79c06f6405f..df110449f6f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelPackageableElementCompartmentEditPartTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ModelPackageableElementCompartmentEditPartTN.java
@@ -1,129 +1,135 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ModelPackageableElementCompartmentItemSemanticEditPolicyTN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class ModelPackageableElementCompartmentEditPartTN extends ShapeCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1057;
-
- /**
- * @generated
- */
- public ModelPackageableElementCompartmentEditPartTN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.ModelPackageableElementCompartmentEditPartTN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ModelPackageableElementCompartmentItemSemanticEditPolicyTN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ModelPackageableElementCompartmentItemSemanticEditPolicyTN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class ModelPackageableElementCompartmentEditPartTN extends ShapeCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1057;
+
+ /**
+ * @generated
+ */
+ public ModelPackageableElementCompartmentEditPartTN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.ModelPackageableElementCompartmentEditPartTN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ModelPackageableElementCompartmentItemSemanticEditPolicyTN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MultiDependencyLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MultiDependencyLabelEditPart.java
index de7612852e7..8b76d1479b8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MultiDependencyLabelEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/MultiDependencyLabelEditPart.java
@@ -1,791 +1,832 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.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.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class MultiDependencyLabelEditPart extends LabelEditPart implements ITextAwareEditPart, IBorderItemEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.MultiDependencyLabelEditPart.VISUAL_ID), new Point(0, 0));
- }
-
- /**
- * @generated
- */
- public MultiDependencyLabelEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- }
-
- /**
- * @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
- */
- @Override
- 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 if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Dependency_2014, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.MultiDependencyLabelEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim() {
- return new WrappingLabel();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class MultiDependencyLabelEditPart extends LabelEditPart implements ITextAwareEditPart, IBorderItemEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.MultiDependencyLabelEditPart.VISUAL_ID), new Point(0, 0));
+ }
+
+ /**
+ * @generated
+ */
+ public MultiDependencyLabelEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ }
+
+ /**
+ * @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
+ */
+ @Override
+ 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 if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Dependency_2014, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.MultiDependencyLabelEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageEditPart.java
index f9486f62376..2174f7240e2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageEditPart.java
@@ -1,294 +1,291 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PackageItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class PackageEditPart extends NamedElementEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2007;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public PackageEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PackageItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new PackageFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure
- *
- * @generated
- */
- @Override
- public PackageFigure getPrimaryShape() {
- return (PackageFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof PackageNameEditPart) {
- ((PackageNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof PackagePackageableElementCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((PackagePackageableElementCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof PackageNameEditPart) {
- return true;
- }
- if (childEditPart instanceof PackagePackageableElementCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- pane.remove(((PackagePackageableElementCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof PackagePackageableElementCompartmentEditPart) {
- return getPrimaryShape().getPackageableElementFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(200, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(PackageNameEditPart.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PackageItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class PackageEditPart extends NamedElementEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2007;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public PackageEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PackageItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new PackageFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure
+ *
+ * @generated
+ */
+ @Override
+ public PackageFigure getPrimaryShape() {
+ return (PackageFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof PackageNameEditPart) {
+ ((PackageNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof PackagePackageableElementCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((PackagePackageableElementCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof PackageNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof PackagePackageableElementCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ pane.remove(((PackagePackageableElementCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof PackagePackageableElementCompartmentEditPart) {
+ return getPrimaryShape().getPackageableElementFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(200, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(PackageNameEditPart.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageEditPartCN.java
index 417f6e33bba..32e06a8de0b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageEditPartCN.java
@@ -1,298 +1,295 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PackageItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class PackageEditPartCN extends NamedElementEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1012;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public PackageEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PackageItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new PackageFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure
- *
- * @generated
- */
- @Override
- public PackageFigure getPrimaryShape() {
- return (PackageFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof PackageNameEditPartCN) {
- ((PackageNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof PackagePackageableElementCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((PackagePackageableElementCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof PackageNameEditPartCN) {
- return true;
- }
- if (childEditPart instanceof PackagePackageableElementCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- pane.remove(((PackagePackageableElementCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof PackagePackageableElementCompartmentEditPartCN) {
- return getPrimaryShape().getPackageableElementFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(PackageNameEditPartCN.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PackageItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class PackageEditPartCN extends NamedElementEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1012;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public PackageEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PackageItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new PackageFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure
+ *
+ * @generated
+ */
+ @Override
+ public PackageFigure getPrimaryShape() {
+ return (PackageFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof PackageNameEditPartCN) {
+ ((PackageNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof PackagePackageableElementCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((PackagePackageableElementCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof PackageNameEditPartCN) {
+ return true;
+ }
+ if (childEditPart instanceof PackagePackageableElementCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ pane.remove(((PackagePackageableElementCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof PackagePackageableElementCompartmentEditPartCN) {
+ return getPrimaryShape().getPackageableElementFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(PackageNameEditPartCN.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageImportAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageImportAppliedStereotypeEditPart.java
index 73454b7b832..08edf71d7f3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageImportAppliedStereotypeEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageImportAppliedStereotypeEditPart.java
@@ -1,760 +1,802 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ConnectionLocator;
-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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultLinkLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class PackageImportAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 6022;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
- /**
- * @generated
- */
- static {
- registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60));
- }
-
- /**
- * @generated
- */
- public PackageImportAppliedStereotypeEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- public int getKeyPoint() {
- return ConnectionLocator.MIDDLE;
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.PackageImport_1065, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportAppliedStereotypeEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- // The label is read-only (defined in GMFGen model)
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultLinkLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class PackageImportAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 6022;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60));
+ }
+
+ /**
+ * @generated
+ */
+ public PackageImportAppliedStereotypeEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultLinkLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getKeyPoint() {
+ return ConnectionLocator.MIDDLE;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.PackageImport_1065, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportAppliedStereotypeEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ // The label is read-only (defined in GMFGen model)
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageImportEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageImportEditPart.java
index 5dd960d3b5e..9af52d2520d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageImportEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageImportEditPart.java
@@ -1,117 +1,118 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypePackageImportLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.edge.DashedEdgeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PackageImportItemSemanticEditPolicy;
-
-/**
- * @generated
- */
-public class PackageImportEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1065;
-
- /**
- * @generated
- */
- public PackageImportEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PackageImportItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypePackageImportLabelDisplayEditPolicy());
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof PackageImportAppliedStereotypeEditPart) {
- ((PackageImportAppliedStereotypeEditPart) childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel());
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof PackageImportAppliedStereotypeEditPart) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * 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
- */
- @Override
- protected Connection createConnectionFigure() {
- return new DashedEdgeFigure();
- }
-
- /**
- * @generated
- */
- @Override
- public DashedEdgeFigure getPrimaryShape() {
- return (DashedEdgeFigure) getFigure();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypePackageImportLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.edge.DashedEdgeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PackageImportItemSemanticEditPolicy;
+
+/**
+ * @generated
+ */
+public class PackageImportEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1065;
+
+ /**
+ * @generated
+ */
+ public PackageImportEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PackageImportItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypePackageImportLabelDisplayEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof PackageImportAppliedStereotypeEditPart) {
+ ((PackageImportAppliedStereotypeEditPart) childEditPart).setLabel(
+ getPrimaryShape().getAppliedStereotypeLabel());
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof PackageImportAppliedStereotypeEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ protected Connection createConnectionFigure() {
+ return new DashedEdgeFigure();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public DashedEdgeFigure getPrimaryShape() {
+ return (DashedEdgeFigure) getFigure();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageNameEditPart.java
index c7099a7dde9..efa0b23d769 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageNameEditPart.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class PackageNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5026;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public PackageNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Package_2007, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class PackageNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5026;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public PackageNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Package_2007, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageNameEditPartCN.java
index 60dc8e584a8..0be383c18ce 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackageNameEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1010;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public PackageNameEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Package_1012, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageNameEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1010;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public PackageNameEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Package_1012, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageNameEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackagePackageableElementCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackagePackageableElementCompartmentEditPart.java
index 1c9763e8419..1ab87324141 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackagePackageableElementCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackagePackageableElementCompartmentEditPart.java
@@ -1,127 +1,133 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PackagePackageableElementCompartmentItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class PackagePackageableElementCompartmentEditPart extends ShapeCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1005;
-
- /**
- * @generated
- */
- public PackagePackageableElementCompartmentEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.PackagePackageableElementCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PackagePackageableElementCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PackagePackageableElementCompartmentItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class PackagePackageableElementCompartmentEditPart extends ShapeCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1005;
+
+ /**
+ * @generated
+ */
+ public PackagePackageableElementCompartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.PackagePackageableElementCompartmentEditPart_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PackagePackageableElementCompartmentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackagePackageableElementCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackagePackageableElementCompartmentEditPartCN.java
index d8f0d82de1b..6c00e1c2fd5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackagePackageableElementCompartmentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PackagePackageableElementCompartmentEditPartCN.java
@@ -1,127 +1,133 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PackagePackageableElementCompartmentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class PackagePackageableElementCompartmentEditPartCN extends ShapeCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 11;
-
- /**
- * @generated
- */
- public PackagePackageableElementCompartmentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.PackagePackageableElementCompartmentEditPartCN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PackagePackageableElementCompartmentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PackagePackageableElementCompartmentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class PackagePackageableElementCompartmentEditPartCN extends ShapeCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 11;
+
+ /**
+ * @generated
+ */
+ public PackagePackageableElementCompartmentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.PackagePackageableElementCompartmentEditPartCN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PackagePackageableElementCompartmentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeEditPart.java
index 40e5ce854f4..eb6929a7d27 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeEditPart.java
@@ -1,278 +1,275 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.PrimitiveTypeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomPrimitiveTypeItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PrimitiveTypeItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class PrimitiveTypeEditPart extends ClassifierEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2009;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public PrimitiveTypeEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PrimitiveTypeItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomPrimitiveTypeItemSemanticEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new PrimitiveTypeFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.PrimitiveTypeFigure
- *
- * @generated
- */
- @Override
- public PrimitiveTypeFigure getPrimaryShape() {
- return (PrimitiveTypeFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof PrimitiveTypeNameEditPart) {
- ((PrimitiveTypeNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof PrimitiveTypeNameEditPart) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(PrimitiveTypeNameEditPart.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.PrimitiveTypeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomPrimitiveTypeItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PrimitiveTypeItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class PrimitiveTypeEditPart extends ClassifierEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2009;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public PrimitiveTypeEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PrimitiveTypeItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomPrimitiveTypeItemSemanticEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new PrimitiveTypeFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.PrimitiveTypeFigure
+ *
+ * @generated
+ */
+ @Override
+ public PrimitiveTypeFigure getPrimaryShape() {
+ return (PrimitiveTypeFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof PrimitiveTypeNameEditPart) {
+ ((PrimitiveTypeNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof PrimitiveTypeNameEditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(PrimitiveTypeNameEditPart.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeEditPartCN.java
index 15cba64c63e..0f1e9ff6111 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeEditPartCN.java
@@ -1,278 +1,275 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.PrimitiveTypeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomPrimitiveTypeItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PrimitiveTypeItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class PrimitiveTypeEditPartCN extends ClassifierEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3026;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public PrimitiveTypeEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PrimitiveTypeItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomPrimitiveTypeItemSemanticEditPolicyCN());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new PrimitiveTypeFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.PrimitiveTypeFigure
- *
- * @generated
- */
- @Override
- public PrimitiveTypeFigure getPrimaryShape() {
- return (PrimitiveTypeFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof PrimitiveTypeNameEditPartCN) {
- ((PrimitiveTypeNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof PrimitiveTypeNameEditPartCN) {
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(PrimitiveTypeNameEditPartCN.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.PrimitiveTypeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomPrimitiveTypeItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.PrimitiveTypeItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class PrimitiveTypeEditPartCN extends ClassifierEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3026;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public PrimitiveTypeEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PrimitiveTypeItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomPrimitiveTypeItemSemanticEditPolicyCN());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new PrimitiveTypeFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.PrimitiveTypeFigure
+ *
+ * @generated
+ */
+ @Override
+ public PrimitiveTypeFigure getPrimaryShape() {
+ return (PrimitiveTypeFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof PrimitiveTypeNameEditPartCN) {
+ ((PrimitiveTypeNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof PrimitiveTypeNameEditPartCN) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(PrimitiveTypeNameEditPartCN.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeNameEditPart.java
index ee25cb4c8ea..12d8995dd5e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeNameEditPart.java
@@ -1,826 +1,867 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
-import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class PrimitiveTypeNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5032;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public PrimitiveTypeNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @generated
- */
- protected EObject getParserElement() {
- return resolveSemanticElement();
- }
-
- /**
- * @generated
- */
- protected Image getLabelIcon() {
- EObject parserElement = getParserElement();
- if (parserElement == null) {
- return null;
- }
- List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer());
- for (View view : views) {
- if (AppearanceHelper.showElementIcon(view)) {
- return UMLElementTypes.getImage(parserElement.eClass());
- }
- }
- 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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.PrimitiveType_2009, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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();
- }
- }
- }
- if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation) event.getNewValue()).getSource())) {
- refreshLabel();
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
+import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class PrimitiveTypeNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5032;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public PrimitiveTypeNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer());
+ for (View view : views) {
+ if (AppearanceHelper.showElementIcon(view)) {
+ return UMLElementTypes.getImage(parserElement.eClass());
+ }
+ }
+ 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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.PrimitiveType_2009, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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();
+ }
+ }
+ }
+ if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation) event.getNewValue()).getSource())) {
+ refreshLabel();
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeNameEditPartCN.java
index 8968aa256dd..66fa249439b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/PrimitiveTypeNameEditPartCN.java
@@ -1,826 +1,867 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
-import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class PrimitiveTypeNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5058;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public PrimitiveTypeNameEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @generated
- */
- protected EObject getParserElement() {
- return resolveSemanticElement();
- }
-
- /**
- * @generated
- */
- protected Image getLabelIcon() {
- EObject parserElement = getParserElement();
- if (parserElement == null) {
- return null;
- }
- List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer());
- for (View view : views) {
- if (AppearanceHelper.showElementIcon(view)) {
- return UMLElementTypes.getImage(parserElement.eClass());
- }
- }
- 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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.PrimitiveType_3026, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeNameEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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();
- }
- }
- }
- if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation) event.getNewValue()).getSource())) {
- refreshLabel();
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
+import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class PrimitiveTypeNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5058;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public PrimitiveTypeNameEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer());
+ for (View view : views) {
+ if (AppearanceHelper.showElementIcon(view)) {
+ return UMLElementTypes.getImage(parserElement.eClass());
+ }
+ }
+ 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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.PrimitiveType_3026, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeNameEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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();
+ }
+ }
+ }
+ if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation) event.getNewValue()).getSource())) {
+ refreshLabel();
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileEditPartCN.java
index b7375365017..7ac4a9d8c7c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileEditPartCN.java
@@ -1,294 +1,291 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ProfileFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ProfileItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class ProfileEditPartCN extends NamedElementEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1024;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public ProfileEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ProfileItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new ProfileFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.ProfileFigure
- *
- * @generated
- */
- @Override
- public ProfileFigure getPrimaryShape() {
- return (ProfileFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ProfileNameEditPartCN) {
- ((ProfileNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof ProfilePackageableElementCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((ProfilePackageableElementCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ProfileNameEditPartCN) {
- return true;
- }
- if (childEditPart instanceof ProfilePackageableElementCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- pane.remove(((ProfilePackageableElementCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof ProfilePackageableElementCompartmentEditPartCN) {
- return getPrimaryShape().getPackageableElementFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(200, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ProfileNameEditPartCN.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ProfileFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ProfileItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ProfileEditPartCN extends NamedElementEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1024;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ProfileEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ProfileItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new ProfileFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.ProfileFigure
+ *
+ * @generated
+ */
+ @Override
+ public ProfileFigure getPrimaryShape() {
+ return (ProfileFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ProfileNameEditPartCN) {
+ ((ProfileNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof ProfilePackageableElementCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((ProfilePackageableElementCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ProfileNameEditPartCN) {
+ return true;
+ }
+ if (childEditPart instanceof ProfilePackageableElementCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ pane.remove(((ProfilePackageableElementCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof ProfilePackageableElementCompartmentEditPartCN) {
+ return getPrimaryShape().getPackageableElementFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(200, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ProfileNameEditPartCN.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileEditPartTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileEditPartTN.java
index c22a64f65e3..5a9224e8517 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileEditPartTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileEditPartTN.java
@@ -1,294 +1,291 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ProfileFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ProfileItemSemanticEditPolicyTN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class ProfileEditPartTN extends NamedElementEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1030;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public ProfileEditPartTN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ProfileItemSemanticEditPolicyTN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new ProfileFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.ProfileFigure
- *
- * @generated
- */
- @Override
- public ProfileFigure getPrimaryShape() {
- return (ProfileFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ProfileNameEditPartTN) {
- ((ProfileNameEditPartTN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof ProfilePackageableElementCompartmentEditPartTN) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((ProfilePackageableElementCompartmentEditPartTN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof ProfileNameEditPartTN) {
- return true;
- }
- if (childEditPart instanceof ProfilePackageableElementCompartmentEditPartTN) {
- IFigure pane = getPrimaryShape().getPackageableElementFigure();
- pane.remove(((ProfilePackageableElementCompartmentEditPartTN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof ProfilePackageableElementCompartmentEditPartTN) {
- return getPrimaryShape().getPackageableElementFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(200, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(ProfileNameEditPartTN.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ProfileFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ProfileItemSemanticEditPolicyTN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ProfileEditPartTN extends NamedElementEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1030;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ProfileEditPartTN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ProfileItemSemanticEditPolicyTN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new ProfileFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.ProfileFigure
+ *
+ * @generated
+ */
+ @Override
+ public ProfileFigure getPrimaryShape() {
+ return (ProfileFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ProfileNameEditPartTN) {
+ ((ProfileNameEditPartTN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof ProfilePackageableElementCompartmentEditPartTN) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((ProfilePackageableElementCompartmentEditPartTN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ProfileNameEditPartTN) {
+ return true;
+ }
+ if (childEditPart instanceof ProfilePackageableElementCompartmentEditPartTN) {
+ IFigure pane = getPrimaryShape().getPackageableElementFigure();
+ pane.remove(((ProfilePackageableElementCompartmentEditPartTN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof ProfilePackageableElementCompartmentEditPartTN) {
+ return getPrimaryShape().getPackageableElementFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(200, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(ProfileNameEditPartTN.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileNameEditPartCN.java
index ec1f09f7b00..5bce44711d9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileNameEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ProfileNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1050;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ProfileNameEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Profile_1024, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileNameEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ProfileNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1050;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ProfileNameEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Profile_1024, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileNameEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileNameEditPartTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileNameEditPartTN.java
index 809df5fbdb3..2905915194f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileNameEditPartTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileNameEditPartTN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class ProfileNameEditPartTN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1047;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public ProfileNameEditPartTN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Profile_1030, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileNameEditPartTN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class ProfileNameEditPartTN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1047;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public ProfileNameEditPartTN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Profile_1030, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileNameEditPartTN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfilePackageableElementCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfilePackageableElementCompartmentEditPartCN.java
index cfd9ba4df4b..8c561088a04 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfilePackageableElementCompartmentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfilePackageableElementCompartmentEditPartCN.java
@@ -1,127 +1,133 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ProfilePackageableElementCompartmentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class ProfilePackageableElementCompartmentEditPartCN extends ShapeCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1051;
-
- /**
- * @generated
- */
- public ProfilePackageableElementCompartmentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.ProfilePackageableElementCompartmentEditPartCN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ProfilePackageableElementCompartmentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ProfilePackageableElementCompartmentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class ProfilePackageableElementCompartmentEditPartCN extends ShapeCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1051;
+
+ /**
+ * @generated
+ */
+ public ProfilePackageableElementCompartmentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.ProfilePackageableElementCompartmentEditPartCN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ProfilePackageableElementCompartmentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfilePackageableElementCompartmentEditPartTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfilePackageableElementCompartmentEditPartTN.java
index 99075baa06c..a359d3f1814 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfilePackageableElementCompartmentEditPartTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfilePackageableElementCompartmentEditPartTN.java
@@ -1,127 +1,133 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ProfilePackageableElementCompartmentItemSemanticEditPolicyTN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class ProfilePackageableElementCompartmentEditPartTN extends ShapeCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1042;
-
- /**
- * @generated
- */
- public ProfilePackageableElementCompartmentEditPartTN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.ProfilePackageableElementCompartmentEditPartTN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ProfilePackageableElementCompartmentItemSemanticEditPolicyTN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ProfilePackageableElementCompartmentItemSemanticEditPolicyTN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class ProfilePackageableElementCompartmentEditPartTN extends ShapeCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1042;
+
+ /**
+ * @generated
+ */
+ public ProfilePackageableElementCompartmentEditPartTN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.ProfilePackageableElementCompartmentEditPartTN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ProfilePackageableElementCompartmentItemSemanticEditPolicyTN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ShortCutDiagramEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ShortCutDiagramEditPart.java
index 4af38553106..84363360b73 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ShortCutDiagramEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ShortCutDiagramEditPart.java
@@ -1,269 +1,267 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.emf.common.notify.Notification;
-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.runtime.diagram.ui.editparts.IBorderItemEditPart;
-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.gef.ui.figures.DefaultSizeNodeFigure;
-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractShortCutDiagramEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShortCutDiagramEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.DiagramNodeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ShortCutDiagramItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class ShortCutDiagramEditPart extends AbstractShortCutDiagramEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2016;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public ShortCutDiagramEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ShortCutDiagramItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(EditPolicyRoles.OPEN_ROLE, new ShortCutDiagramEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- View childView = (View) child.getModel();
- switch (UMLVisualIDRegistry.getVisualID(childView)) {
- case DiagramNameEditPart.VISUAL_ID:
- return new BorderItemSelectionEditPolicy() {
-
- @Override
- 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;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- /*
- * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart
- * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)!
- */
- if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) {
- Object notifier = event.getNotifier();
- List<?> modelChildren = ((View) getModel()).getChildren();
- if (!(notifier instanceof Edge)) {
- if (modelChildren.contains(event.getNotifier())) {
- return;
- }
- }
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new DiagramNodeFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.common.figure.node.DiagramNodeFigure
- *
- * @generated
- */
- @Override
- public DiagramNodeFigure getPrimaryShape() {
- return (DiagramNodeFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
- if (borderItemEditPart instanceof DiagramNameEditPart) {
- BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
- locator.setBorderItemOffset(new Dimension(-20, -20));
- borderItemContainer.add(borderItemEditPart.getFigure(), locator);
- } else {
- super.addBorderItem(borderItemContainer, borderItemEditPart);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(20, 20);
- 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
- */
- @Override
- protected NodeFigure createMainFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- protected IFigure setupContentPane(IFigure nodeShape) {
- return nodeShape; // use nodeShape itself as contentPane
- }
-
- /**
- * @generated
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(DiagramNameEditPart.VISUAL_ID));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.emf.common.notify.Notification;
+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.runtime.diagram.ui.editparts.IBorderItemEditPart;
+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.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractShortCutDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShortCutDiagramEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.DiagramNodeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.ShortCutDiagramItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ShortCutDiagramEditPart extends AbstractShortCutDiagramEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2016;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ShortCutDiagramEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ShortCutDiagramItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(EditPolicyRoles.OPEN_ROLE, new ShortCutDiagramEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy());
+ // 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 (UMLVisualIDRegistry.getVisualID(childView)) {
+ case DiagramNameEditPart.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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ /*
+ * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart
+ * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)!
+ */
+ if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) {
+ Object notifier = event.getNotifier();
+ List<?> modelChildren = ((View) getModel()).getChildren();
+ if (!(notifier instanceof Edge)) {
+ if (modelChildren.contains(event.getNotifier())) {
+ return;
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new DiagramNodeFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.common.figure.node.DiagramNodeFigure
+ *
+ * @generated
+ */
+ @Override
+ public DiagramNodeFigure getPrimaryShape() {
+ return (DiagramNodeFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
+ if (borderItemEditPart instanceof DiagramNameEditPart) {
+ BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
+ locator.setBorderItemOffset(new Dimension(-20, -20));
+ borderItemContainer.add(borderItemEditPart.getFigure(), locator);
+ } else
+ {
+ super.addBorderItem(borderItemContainer, borderItemEditPart);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(20, 20);
+ 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
+ */
+ @Override
+ protected NodeFigure createMainFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ protected IFigure setupContentPane(IFigure nodeShape) {
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(DiagramNameEditPart.VISUAL_ID));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeAttributeCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeAttributeCompartmentEditPart.java
index f080eb57936..f68ec7b86c2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeAttributeCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeAttributeCompartmentEditPart.java
@@ -1,136 +1,142 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeAttributeCompartmentItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class StereotypeAttributeCompartmentEditPart extends ResizeableListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1071;
-
- /**
- * @generated
- */
- public StereotypeAttributeCompartmentEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.StereotypeAttributeCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeAttributeCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeAttributeCompartmentItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class StereotypeAttributeCompartmentEditPart extends ResizeableListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1071;
+
+ /**
+ * @generated
+ */
+ public StereotypeAttributeCompartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.StereotypeAttributeCompartmentEditPart_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeAttributeCompartmentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeAttributeCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeAttributeCompartmentEditPartCN.java
index c9d948a3b56..55ccbfe7659 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeAttributeCompartmentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeAttributeCompartmentEditPartCN.java
@@ -1,136 +1,142 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeAttributeCompartmentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class StereotypeAttributeCompartmentEditPartCN extends ResizeableListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1052;
-
- /**
- * @generated
- */
- public StereotypeAttributeCompartmentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.StereotypeAttributeCompartmentEditPartCN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeAttributeCompartmentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeAttributeCompartmentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class StereotypeAttributeCompartmentEditPartCN extends ResizeableListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1052;
+
+ /**
+ * @generated
+ */
+ public StereotypeAttributeCompartmentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.StereotypeAttributeCompartmentEditPartCN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeAttributeCompartmentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeEditPart.java
index f699c15fa96..0f30fdf8363 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeEditPart.java
@@ -1,342 +1,341 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideClassifierContentsEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.figure.StereotypeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomStereotypeItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class StereotypeEditPart extends ClassifierEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1026;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public StereotypeEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomStereotypeItemSemanticEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- // set the figure active when the feature of the of a class is true
- if (resolveSemanticElement() != null) {
- if (resolveSemanticElement().equals(event.getNotifier()) && (event.getFeature() instanceof EAttribute) && ((EAttribute) (event.getFeature())).getName().equals("isActive")) {
- ((ClassifierFigure) getFigure()).setActive(event.getNewBooleanValue());
- refreshVisuals();
- }
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new StereotypeFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.profile.custom.figure.StereotypeFigure
- *
- * @generated
- */
- @Override
- public StereotypeFigure getPrimaryShape() {
- return (StereotypeFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof StereotypeNameEditPart) {
- ((StereotypeNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof StereotypeAttributeCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((StereotypeAttributeCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof StereotypeOperationCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((StereotypeOperationCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof StereotypeNameEditPart) {
- return true;
- }
- if (childEditPart instanceof StereotypeAttributeCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- pane.remove(((StereotypeAttributeCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof StereotypeOperationCompartmentEditPart) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- pane.remove(((StereotypeOperationCompartmentEditPart) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof StereotypeAttributeCompartmentEditPart) {
- return getPrimaryShape().getAttributeCompartmentFigure();
- }
- if (editPart instanceof StereotypeOperationCompartmentEditPart) {
- return getPrimaryShape().getOperationCompartmentFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeNameEditPart.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- if (request instanceof CreateViewAndElementRequest) {
- CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
- IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
- if (type == UMLElementTypes.Property_3002) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeAttributeCompartmentEditPart.VISUAL_ID));
- }
- if (type == UMLElementTypes.Operation_3020) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeOperationCompartmentEditPart.VISUAL_ID));
- }
- }
- return super.getTargetEditPart(request);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAttribute;
+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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideClassifierContentsEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.figure.StereotypeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomStereotypeItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class StereotypeEditPart extends ClassEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1026;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public StereotypeEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomStereotypeItemSemanticEditPolicy());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ //set the figure active when the feature of the of a class is true
+ if (resolveSemanticElement() != null) {
+ if (resolveSemanticElement().equals(event.getNotifier()) && (event.getFeature() instanceof EAttribute) && ((EAttribute) (event.getFeature())).getName().equals("isActive")) {
+ ((ClassFigure) getFigure()).setActive(event.getNewBooleanValue());
+ refreshVisuals();
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new StereotypeFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.profile.custom.figure.StereotypeFigure
+ *
+ * @generated
+ */
+ @Override
+ public StereotypeFigure getPrimaryShape() {
+ return (StereotypeFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof StereotypeNameEditPart) {
+ ((StereotypeNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof StereotypeAttributeCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((StereotypeAttributeCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof StereotypeOperationCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((StereotypeOperationCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof StereotypeNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof StereotypeAttributeCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ pane.remove(((StereotypeAttributeCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof StereotypeOperationCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ pane.remove(((StereotypeOperationCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof StereotypeAttributeCompartmentEditPart) {
+ return getPrimaryShape().getAttributeCompartmentFigure();
+ }
+ if (editPart instanceof StereotypeOperationCompartmentEditPart) {
+ return getPrimaryShape().getOperationCompartmentFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeNameEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ if (request instanceof CreateViewAndElementRequest) {
+ CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
+ IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
+ if (type == UMLElementTypes.Property_3002) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeAttributeCompartmentEditPart.VISUAL_ID));
+ }
+ if (type == UMLElementTypes.Operation_3020) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeOperationCompartmentEditPart.VISUAL_ID));
+ }
+ }
+ return super.getTargetEditPart(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeEditPartCN.java
index c79b1732e43..1c8a8d63aef 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeEditPartCN.java
@@ -1,342 +1,341 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideClassifierContentsEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.figure.StereotypeFigure;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomStereotypeItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class StereotypeEditPartCN extends ClassifierEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1023;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public StereotypeEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomStereotypeItemSemanticEditPolicyCN());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy());
- // 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() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- /**
- * Papyrus codeGen
- *
- * @generated
- **/
- @Override
- protected void handleNotificationEvent(Notification event) {
- super.handleNotificationEvent(event);
- // set the figure active when the feature of the of a class is true
- if (resolveSemanticElement() != null) {
- if (resolveSemanticElement().equals(event.getNotifier()) && (event.getFeature() instanceof EAttribute) && ((EAttribute) (event.getFeature())).getName().equals("isActive")) {
- ((ClassifierFigure) getFigure()).setActive(event.getNewBooleanValue());
- refreshVisuals();
- }
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new StereotypeFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.profile.custom.figure.StereotypeFigure
- *
- * @generated
- */
- @Override
- public StereotypeFigure getPrimaryShape() {
- return (StereotypeFigure) primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof StereotypeNameEditPartCN) {
- ((StereotypeNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
- return true;
- }
- if (childEditPart instanceof StereotypeAttributeCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((StereotypeAttributeCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof StereotypeOperationCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((StereotypeOperationCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart) {
- if (childEditPart instanceof StereotypeNameEditPartCN) {
- return true;
- }
- if (childEditPart instanceof StereotypeAttributeCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
- pane.remove(((StereotypeAttributeCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof StereotypeOperationCompartmentEditPartCN) {
- IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
- pane.remove(((StereotypeOperationCompartmentEditPartCN) childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- protected void addChildVisual(EditPart childEditPart, int index) {
- if (addFixedChild(childEditPart)) {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeChildVisual(EditPart childEditPart) {
- if (removeFixedChild(childEditPart)) {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof StereotypeAttributeCompartmentEditPartCN) {
- return getPrimaryShape().getAttributeCompartmentFigure();
- }
- if (editPart instanceof StereotypeOperationCompartmentEditPartCN) {
- return getPrimaryShape().getOperationCompartmentFigure();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected NodeFigure createNodePlate() {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
- 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
- */
- @Override
- protected NodeFigure createNodeFigure() {
- return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
- }
-
- /**
- * 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
- */
- @Override
- 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
- */
- @Override
- public IFigure getContentPane() {
- if (contentPane != null) {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- /**
- * @generated
- */
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getPrimaryChildEditPart() {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeNameEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- if (request instanceof CreateViewAndElementRequest) {
- CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
- IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
- if (type == UMLElementTypes.Property_3002) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeAttributeCompartmentEditPartCN.VISUAL_ID));
- }
- if (type == UMLElementTypes.Operation_3020) {
- return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeOperationCompartmentEditPartCN.VISUAL_ID));
- }
- }
- return super.getTargetEditPart(request);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAttribute;
+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.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+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.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ConstrainedItemBorderLayoutEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideClassifierContentsEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.figure.StereotypeFigure;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic.CustomStereotypeItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class StereotypeEditPartCN extends ClassEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1023;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public StereotypeEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
+ installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomStereotypeItemSemanticEditPolicyCN());
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy());
+ // 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;
+ }
+
+ /**
+ * Papyrus codeGen
+ *
+ * @generated
+ **/
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ //set the figure active when the feature of the of a class is true
+ if (resolveSemanticElement() != null) {
+ if (resolveSemanticElement().equals(event.getNotifier()) && (event.getFeature() instanceof EAttribute) && ((EAttribute) (event.getFeature())).getName().equals("isActive")) {
+ ((ClassFigure) getFigure()).setActive(event.getNewBooleanValue());
+ refreshVisuals();
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure createNodeShape() {
+ return primaryShape = new StereotypeFigure();
+ }
+
+ /**
+ * org.eclipse.papyrus.uml.diagram.profile.custom.figure.StereotypeFigure
+ *
+ * @generated
+ */
+ @Override
+ public StereotypeFigure getPrimaryShape() {
+ return (StereotypeFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof StereotypeNameEditPartCN) {
+ ((StereotypeNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof StereotypeAttributeCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((StereotypeAttributeCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof StereotypeOperationCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((StereotypeOperationCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof StereotypeNameEditPartCN) {
+ return true;
+ }
+ if (childEditPart instanceof StereotypeAttributeCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getAttributeCompartmentFigure();
+ pane.remove(((StereotypeAttributeCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ if (childEditPart instanceof StereotypeOperationCompartmentEditPartCN) {
+ IFigure pane = getPrimaryShape().getOperationCompartmentFigure();
+ pane.remove(((StereotypeOperationCompartmentEditPartCN) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof StereotypeAttributeCompartmentEditPartCN) {
+ return getPrimaryShape().getAttributeCompartmentFigure();
+ }
+ if (editPart instanceof StereotypeOperationCompartmentEditPartCN) {
+ return getPrimaryShape().getOperationCompartmentFigure();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(100, 100);
+ 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
+ */
+ @Override
+ protected NodeFigure createNodeFigure() {
+ return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ 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
+ */
+ @Override
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineWidth(int width) {
+ super.setLineWidth(width);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setLineType(int style) {
+ if (primaryShape instanceof IPapyrusNodeFigure) {
+ ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeNameEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ if (request instanceof CreateViewAndElementRequest) {
+ CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
+ IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
+ if (type == UMLElementTypes.Property_3002) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeAttributeCompartmentEditPartCN.VISUAL_ID));
+ }
+ if (type == UMLElementTypes.Operation_3020) {
+ return getChildBySemanticHint(UMLVisualIDRegistry.getType(StereotypeOperationCompartmentEditPartCN.VISUAL_ID));
+ }
+ }
+ return super.getTargetEditPart(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeNameEditPart.java
index a2cdc34c40d..85850e2065f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeNameEditPart.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class StereotypeNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1034;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public StereotypeNameEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Stereotype_1026, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class StereotypeNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1034;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public StereotypeNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Stereotype_1026, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeNameEditPartCN.java
index 8b1136cff8c..fb0e1bf0791 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeNameEditPartCN.java
@@ -1,809 +1,850 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-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.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.ParserOptions;
-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.edit.policies.DefaultNodeLabelDragPolicy;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * @generated
- */
-public class StereotypeNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1046;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List<?> parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * direct edition mode (default, undefined, registered editor, etc.)
- *
- * @generated
- */
- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
-
- /**
- * configuration from a registered edit dialog
- *
- * @generated
- */
- protected IDirectEditorConfiguration configuration;
-
- /**
- * @generated
- */
- public StereotypeNameEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getText();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getText();
- } else {
- return ((Label) figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setText(text);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setText(text);
- } else {
- ((Label) figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure) {
- if (figure instanceof WrappingLabel) {
- return ((WrappingLabel) figure).getIcon();
- } else if (figure instanceof ILabelFigure) {
- return ((ILabelFigure) figure).getIcon();
- } else {
- return ((Label) figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon) {
- if (figure instanceof WrappingLabel) {
- ((WrappingLabel) figure).setIcon(icon);
- } else if (figure instanceof ILabelFigure) {
- ((ILabelFigure) figure).setIcon(icon);
- } else {
- ((Label) figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> getModelChildren() {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- @Override
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
-
- /**
- * @generated
- */
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @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 UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
-
- public void run() {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
- }
- });
- return valid.getCode() == IParserEditStatus.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 = UMLParserProvider.getParser(UMLElementTypes.Stereotype_1023, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeNameEditPartCN.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager() {
- if (manager == null) {
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager) {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit() {
- BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
-
- public void run() {
- getManager().show();
- }
- });
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter) {
- if (getManager() instanceof TextDirectEditManager) {
- ((TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void performDirectEditRequest(Request request) {
- final Request theRequest = request;
- if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
- directEditionMode = getDirectEditionType();
- }
- switch (directEditionMode) {
- case IDirectEdition.NO_DIRECT_EDITION:
- // no direct edition mode => does nothing
- return;
- case IDirectEdition.EXTENDED_DIRECT_EDITOR:
- updateExtendedEditorConfiguration();
- if (configuration == null || configuration.getLanguage() == null) {
- // Create default edit manager
- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
- performDefaultDirectEditorEdit(theRequest);
- } else {
- configuration.preEditAction(resolveSemanticElement());
- Dialog dialog = null;
- if (configuration instanceof ICustomDirectEditorConfiguration) {
- setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
- initializeDirectEditManager(theRequest);
- return;
- } else if (configuration instanceof IPopupEditorConfiguration) {
- IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
- helper.showEditor();
- return;
- } else if (configuration instanceof IAdvancedEditorConfiguration) {
- dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
- } else if (configuration instanceof IDirectEditorConfiguration) {
- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
- } else {
- return;
- }
- final Dialog finalDialog = dialog;
- if (Window.OK == dialog.open()) {
- TransactionalEditingDomain domain = getEditingDomain();
- RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
-
- @Override
- protected void doExecute() {
- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
- }
- };
- domain.getCommandStack().execute(command);
- }
- }
- break;
- case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- initializeDirectEditManager(theRequest);
- break;
- default:
- break;
- }
- }
-
- /**
- * @generated
- */
- protected void initializeDirectEditManager(final Request request) {
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if (isActive() && isEditable()) {
- if (request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel() {
- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
- if (maskLabelPolicy == null) {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- }
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
- ((UMLTextSelectionEditPolicy) 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());
- }
- if (resolveSemanticElement() instanceof Feature) {
- if (((Feature) resolveSemanticElement()).isStatic()) {
- ((WrappingLabel) getFigure()).setTextUnderline(true);
- } else {
- ((WrappingLabel) getFigure()).setTextUnderline(false);
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough() {
- FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void setFontColor(Color color) {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- @Override
- 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
- */
- @Override
- protected void removeSemanticListeners() {
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- } else {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected AccessibleEditPart getAccessibleEditPart() {
- if (accessibleEP == null) {
- accessibleEP = new AccessibleGraphicalEditPart() {
-
- @Override
- public void getName(AccessibleEvent e) {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView() {
- return getPrimaryView();
- }
-
- /**
- * Returns the kind of associated editor for direct edition.
- *
- * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
- * @generated
- */
- public int getDirectEditionType() {
- if (checkExtendedEditor()) {
- initExtendedEditorConfiguration();
- return IDirectEdition.EXTENDED_DIRECT_EDITOR;
- }
- if (checkDefaultEdition()) {
- return IDirectEdition.DEFAULT_DIRECT_EDITOR;
- }
- // not a named element. no specific editor => do nothing
- return IDirectEdition.NO_DIRECT_EDITION;
- }
-
- /**
- * Checks if an extended editor is present.
- *
- * @return <code>true</code> if an extended editor is present.
- * @generated
- */
- protected boolean checkExtendedEditor() {
- if (resolveSemanticElement() != null) {
- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
- }
- return false;
- }
-
- /**
- * Checks if a default direct edition is available
- *
- * @return <code>true</code> if a default direct edition is available
- * @generated
- */
- protected boolean checkDefaultEdition() {
- return (getParser() != null);
- }
-
- /**
- * Initializes the extended editor configuration
- *
- * @generated
- */
- protected void initExtendedEditorConfiguration() {
- if (configuration == null) {
- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("")) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
- }
- }
- }
-
- /**
- * Updates the preference configuration
- *
- * @generated
- */
- protected void updateExtendedEditorConfiguration() {
- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
- } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
- configuration = null;
- }
- }
-
- /**
- * Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
- * @generated
- */
- protected void performDefaultDirectEditorEdit(final Request theRequest) {
- // initialize the direct edit manager
- 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
- */
- @Override
- protected void addNotationalListeners() {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void removeNotationalListeners() {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- refreshLabel();
- 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
- */
- @Override
- protected IFigure createFigure() {
- // Parent should assign one using setLabel() method
- return null;
- }
-
- /**
- * @generated
- */
- private static final String ADD_PARENT_MODEL = "AddParentModel";
-
- /**
- * @generated
- */
- @Override
- public void activate() {
- super.activate();
- addOwnerElementListeners();
- }
-
- /**
- * @generated
- */
- protected void addOwnerElementListeners() {
- addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel()));
- }
-
- /**
- * @generated
- */
- @Override
- public void deactivate() {
- removeOwnerElementListeners();
- super.deactivate();
- }
-
- /**
- * @generated
- */
- protected void removeOwnerElementListeners() {
- removeListenerFilter(ADD_PARENT_MODEL);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.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.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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.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.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.edit.policies.DefaultNodeLabelDragPolicy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+/**
+ * @generated
+ */
+public class StereotypeNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1046;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * direct edition mode (default, undefined, registered editor, etc.)
+ *
+ * @generated
+ */
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ /**
+ * configuration from a registered edit dialog
+ *
+ * @generated
+ */
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * @generated
+ */
+ public StereotypeNameEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else if (figure instanceof ILabelFigure) {
+ return ((ILabelFigure) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else if (figure instanceof ILabelFigure) {
+ ((ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure
+ figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @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 UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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<java.lang.Object>() {
+
+ 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 = UMLParserProvider.getParser(UMLElementTypes.Stereotype_1023, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeNameEditPartCN.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this,
+ MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ UMLEditPartFactory.getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if (configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ }
+ else if (configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if (configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration) configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration) configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if (Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (maskLabelPolicy == null) {
+ maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ View view = (View) getModel();
+ if (view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy) 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());
+ }
+ if (resolveSemanticElement() instanceof Feature) {
+ if (((Feature) resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel) getFigure()).setTextUnderline(true);
+ }
+ else {
+ ((WrappingLabel) getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style =
+ (FontStyle) getFontStyleOwnerView().getStyle(
+ NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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
+ */
+ @Override
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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();
+ }
+
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ /**
+ * Initializes the extended editor configuration
+ *
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ /**
+ * Updates the preference configuration
+ *
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(
+ IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement()
+ .eClass().getInstanceClassName());
+ } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ *
+ * @param theRequest
+ * the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ 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
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ refreshLabel();
+ 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
+ */
+ @Override
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+ /**
+ * @generated
+ */
+ @Override
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeOperationCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeOperationCompartmentEditPart.java
index 5a88e633e67..a78019d488b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeOperationCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeOperationCompartmentEditPart.java
@@ -1,136 +1,142 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeOperationCompartmentItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class StereotypeOperationCompartmentEditPart extends ResizeableListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1019;
-
- /**
- * @generated
- */
- public StereotypeOperationCompartmentEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.StereotypeOperationCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeOperationCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeOperationCompartmentItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class StereotypeOperationCompartmentEditPart extends ResizeableListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1019;
+
+ /**
+ * @generated
+ */
+ public StereotypeOperationCompartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.StereotypeOperationCompartmentEditPart_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeOperationCompartmentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeOperationCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeOperationCompartmentEditPartCN.java
index c14cce98b20..ef3f09cfb32 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeOperationCompartmentEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/StereotypeOperationCompartmentEditPartCN.java
@@ -1,136 +1,142 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-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.editpolicies.ResizableCompartmentEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeOperationCompartmentItemSemanticEditPolicyCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-
-/**
- * @generated
- */
-public class StereotypeOperationCompartmentEditPartCN extends ResizeableListCompartmentEditPart {
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1053;
-
- /**
- * @generated
- */
- public StereotypeOperationCompartmentEditPartCN(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean hasModelChildrenChanged(Notification evt) {
- return false;
- }
-
- /**
- * @generated
- */
- @Override
- public String getCompartmentName() {
- return Messages.StereotypeOperationCompartmentEditPartCN_title;
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeOperationCompartmentItemSemanticEditPolicyCN());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
- }
-
- /**
- * @generated
- */
- @Override
- protected void setRatio(Double ratio) {
- if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
- super.setRatio(ratio);
- }
- }
-
- /**
- * @generated
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- @Override
- protected void handleNotificationEvent(Notification notification) {
- Object feature = notification.getFeature();
- if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
- refreshBounds();
- }
- super.handleNotificationEvent(notification);
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshBounds() {
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size));
- }
-
- /**
- * @generated
- */
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshBounds();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+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.editpolicies.ResizableCompartmentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ResizeableListCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.StereotypeOperationCompartmentItemSemanticEditPolicyCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+
+/**
+ * @generated
+ */
+public class StereotypeOperationCompartmentEditPartCN extends ResizeableListCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1053;
+
+ /**
+ * @generated
+ */
+ public StereotypeOperationCompartmentEditPartCN(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean hasModelChildrenChanged(Notification evt) {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getCompartmentName() {
+ return Messages.StereotypeOperationCompartmentEditPartCN_title;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy());
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new StereotypeOperationCompartmentItemSemanticEditPolicyCN());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy());
+ installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public EditPart getTargetEditPart(Request request) {
+ return super.getTargetEditPart(request);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void handleNotificationEvent(Notification notification) {
+ Object feature = notification.getFeature();
+ if (NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+ super.handleNotificationEvent(notification);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ Dimension size = new Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ Point loc = new Point(x, y);
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(
+ this,
+ getFigure(),
+ new Rectangle(loc, size));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/UMLEditPartFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/UMLEditPartFactory.java
index e12f7fc1a1f..8c0da386ac3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/UMLEditPartFactory.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/UMLEditPartFactory.java
@@ -1,311 +1,314 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
-
-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.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.tooling.runtime.directedit.locator.CellEditorLocatorAccess;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @generated
- */
-public class UMLEditPartFactory implements EditPartFactory {
-
- /**
- * @generated
- */
- public EditPart createEditPart(EditPart context, Object model) {
- if (model instanceof View) {
- View view = (View) model;
- switch (UMLVisualIDRegistry.getVisualID(view)) {
- case ProfileDiagramEditPart.VISUAL_ID:
- return new ProfileDiagramEditPart(view);
- case DependencyNodeEditPart.VISUAL_ID:
- return new DependencyNodeEditPart(view);
- case MultiDependencyLabelEditPart.VISUAL_ID:
- return new MultiDependencyLabelEditPart(view);
- case AssociationNodeEditPart.VISUAL_ID:
- return new AssociationNodeEditPart(view);
- case StereotypeEditPart.VISUAL_ID:
- return new StereotypeEditPart(view);
- case StereotypeNameEditPart.VISUAL_ID:
- return new StereotypeNameEditPart(view);
- case ClassEditPart.VISUAL_ID:
- return new ClassEditPart(view);
- case ClassNameEditPart.VISUAL_ID:
- return new ClassNameEditPart(view);
- case MetaclassEditPart.VISUAL_ID:
- return new MetaclassEditPart(view);
- case MetaclassNameEditPart.VISUAL_ID:
- return new MetaclassNameEditPart(view);
- case CommentEditPart.VISUAL_ID:
- return new CommentEditPart(view);
- case CommentBodyEditPart.VISUAL_ID:
- return new CommentBodyEditPart(view);
- case ConstraintEditPart.VISUAL_ID:
- return new ConstraintEditPart(view);
- case ConstraintNameEditPart.VISUAL_ID:
- return new ConstraintNameEditPart(view);
- case ConstraintBodyEditPart.VISUAL_ID:
- return new ConstraintBodyEditPart(view);
- case ModelEditPartTN.VISUAL_ID:
- return new ModelEditPartTN(view);
- case ModelNameEditPart.VISUAL_ID:
- return new ModelNameEditPart(view);
- case ProfileEditPartTN.VISUAL_ID:
- return new ProfileEditPartTN(view);
- case ProfileNameEditPartTN.VISUAL_ID:
- return new ProfileNameEditPartTN(view);
- case PackageEditPart.VISUAL_ID:
- return new PackageEditPart(view);
- case PackageNameEditPart.VISUAL_ID:
- return new PackageNameEditPart(view);
- case EnumerationEditPart.VISUAL_ID:
- return new EnumerationEditPart(view);
- case EnumerationNameEditPart.VISUAL_ID:
- return new EnumerationNameEditPart(view);
- case PrimitiveTypeEditPart.VISUAL_ID:
- return new PrimitiveTypeEditPart(view);
- case PrimitiveTypeNameEditPart.VISUAL_ID:
- return new PrimitiveTypeNameEditPart(view);
- case DataTypeEditPart.VISUAL_ID:
- return new DataTypeEditPart(view);
- case DataTypeNameEditPart.VISUAL_ID:
- return new DataTypeNameEditPart(view);
- case ShortCutDiagramEditPart.VISUAL_ID:
- return new ShortCutDiagramEditPart(view);
- case DiagramNameEditPart.VISUAL_ID:
- return new DiagramNameEditPart(view);
- case PrimitiveTypeEditPartCN.VISUAL_ID:
- return new PrimitiveTypeEditPartCN(view);
- case PrimitiveTypeNameEditPartCN.VISUAL_ID:
- return new PrimitiveTypeNameEditPartCN(view);
- case DataTypeOperationEditPart.VISUAL_ID:
- return new DataTypeOperationEditPart(view);
- case EnumerationLiteralEditPart.VISUAL_ID:
- return new EnumerationLiteralEditPart(view);
- case DataTypePropertyEditPart.VISUAL_ID:
- return new DataTypePropertyEditPart(view);
- case ClassPropertyEditPart.VISUAL_ID:
- return new ClassPropertyEditPart(view);
- case ClassOperationEditPart.VISUAL_ID:
- return new ClassOperationEditPart(view);
- case StereotypeEditPartCN.VISUAL_ID:
- return new StereotypeEditPartCN(view);
- case StereotypeNameEditPartCN.VISUAL_ID:
- return new StereotypeNameEditPartCN(view);
- case ClassEditPartCN.VISUAL_ID:
- return new ClassEditPartCN(view);
- case ClassNameEditPartCN.VISUAL_ID:
- return new ClassNameEditPartCN(view);
- case MetaclassEditPartCN.VISUAL_ID:
- return new MetaclassEditPartCN(view);
- case MetaclassNameEditPartCN.VISUAL_ID:
- return new MetaclassNameEditPartCN(view);
- case CommentEditPartCN.VISUAL_ID:
- return new CommentEditPartCN(view);
- case CommentBodyEditPartCN.VISUAL_ID:
- return new CommentBodyEditPartCN(view);
- case ModelEditPartCN.VISUAL_ID:
- return new ModelEditPartCN(view);
- case ModelNameEditPartCN.VISUAL_ID:
- return new ModelNameEditPartCN(view);
- case ProfileEditPartCN.VISUAL_ID:
- return new ProfileEditPartCN(view);
- case ProfileNameEditPartCN.VISUAL_ID:
- return new ProfileNameEditPartCN(view);
- case PackageEditPartCN.VISUAL_ID:
- return new PackageEditPartCN(view);
- case PackageNameEditPartCN.VISUAL_ID:
- return new PackageNameEditPartCN(view);
- case ConstraintEditPartCN.VISUAL_ID:
- return new ConstraintEditPartCN(view);
- case ConstraintNameEditPartCN.VISUAL_ID:
- return new ConstraintNameEditPartCN(view);
- case ConstraintBodyEditPartCN.VISUAL_ID:
- return new ConstraintBodyEditPartCN(view);
- case EnumerationEditPartCN.VISUAL_ID:
- return new EnumerationEditPartCN(view);
- case EnumerationNameEditPartCN.VISUAL_ID:
- return new EnumerationNameEditPartCN(view);
- case DataTypeEditPartCN.VISUAL_ID:
- return new DataTypeEditPartCN(view);
- case DataTypeNameEditPartCN.VISUAL_ID:
- return new DataTypeNameEditPartCN(view);
- case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
- return new PackagePackageableElementCompartmentEditPart(view);
- case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
- return new PackagePackageableElementCompartmentEditPartCN(view);
- case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
- return new ProfilePackageableElementCompartmentEditPartTN(view);
- case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
- return new ProfilePackageableElementCompartmentEditPartCN(view);
- case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
- return new StereotypeAttributeCompartmentEditPart(view);
- case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
- return new StereotypeAttributeCompartmentEditPartCN(view);
- case StereotypeOperationCompartmentEditPart.VISUAL_ID:
- return new StereotypeOperationCompartmentEditPart(view);
- case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
- return new StereotypeOperationCompartmentEditPartCN(view);
- case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
- return new ModelPackageableElementCompartmentEditPartTN(view);
- case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
- return new ModelPackageableElementCompartmentEditPartCN(view);
- case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
- return new EnumerationEnumerationLiteralCompartmentEditPartCN(view);
- case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
- return new EnumerationEnumerationLiteralCompartmentEditPart(view);
- case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
- return new DataTypeAttributeCompartmentEditPart(view);
- case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
- return new DataTypeAttributeCompartmentEditPartCN(view);
- case DataTypeOperationCompartmentEditPart.VISUAL_ID:
- return new DataTypeOperationCompartmentEditPart(view);
- case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
- return new DataTypeOperationCompartmentEditPartCN(view);
- case ClassAttributeCompartmentEditPart.VISUAL_ID:
- return new ClassAttributeCompartmentEditPart(view);
- case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
- return new ClassAttributeCompartmentEditPartCN(view);
- case ClassOperationCompartmentEditPart.VISUAL_ID:
- return new ClassOperationCompartmentEditPart(view);
- case ClassOperationCompartmentEditPartCN.VISUAL_ID:
- return new ClassOperationCompartmentEditPartCN(view);
- case ExtensionEditPart.VISUAL_ID:
- return new ExtensionEditPart(view);
- case AssociationEditPart.VISUAL_ID:
- return new AssociationEditPart(view);
- case AssociationAppliedStereotypeEditPart.VISUAL_ID:
- return new AssociationAppliedStereotypeEditPart(view);
- case AssociationNameEditPart.VISUAL_ID:
- return new AssociationNameEditPart(view);
- case AssociationRoleTargetEditPart.VISUAL_ID:
- return new AssociationRoleTargetEditPart(view);
- case AssociationRoleSourceEditPart.VISUAL_ID:
- return new AssociationRoleSourceEditPart(view);
- case AssociationMultiplicitySourceEditPart.VISUAL_ID:
- return new AssociationMultiplicitySourceEditPart(view);
- case AssociationMultiplicityTargetEditPart.VISUAL_ID:
- return new AssociationMultiplicityTargetEditPart(view);
- case ProfileApplicationEditPart.VISUAL_ID:
- return new ProfileApplicationEditPart(view);
- case AssociationBranchEditPart.VISUAL_ID:
- return new AssociationBranchEditPart(view);
- case AssociationBranchRoleEditPart.VISUAL_ID:
- return new AssociationBranchRoleEditPart(view);
- case AssociationBranchMultiplicityEditPart.VISUAL_ID:
- return new AssociationBranchMultiplicityEditPart(view);
- case GeneralizationEditPart.VISUAL_ID:
- return new GeneralizationEditPart(view);
- case GeneralizationAppliedStereotypeEditPart.VISUAL_ID:
- return new GeneralizationAppliedStereotypeEditPart(view);
- case DependencyEditPart.VISUAL_ID:
- return new DependencyEditPart(view);
- case DependencyNameEditPart.VISUAL_ID:
- return new DependencyNameEditPart(view);
- case DependencyAppliedStereotypeEditPart.VISUAL_ID:
- return new DependencyAppliedStereotypeEditPart(view);
- case DependencyBranchEditPart.VISUAL_ID:
- return new DependencyBranchEditPart(view);
- case ElementImportEditPart.VISUAL_ID:
- return new ElementImportEditPart(view);
- case ElementImportAliasEditPart.VISUAL_ID:
- return new ElementImportAliasEditPart(view);
- case AppliedStereotypeElementImportEditPart.VISUAL_ID:
- return new AppliedStereotypeElementImportEditPart(view);
- case PackageImportEditPart.VISUAL_ID:
- return new PackageImportEditPart(view);
- case PackageImportAppliedStereotypeEditPart.VISUAL_ID:
- return new PackageImportAppliedStereotypeEditPart(view);
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return new CommentAnnotatedElementEditPart(view);
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return new ConstraintConstrainedElementEditPart(view);
- case ContextLinkEditPart.VISUAL_ID:
- return new ContextLinkEditPart(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 IMultilineEditableFigure) {
- return new MultilineCellEditorLocator((IMultilineEditableFigure) source.getFigure());
- } else {
- return CellEditorLocatorAccess.INSTANCE.getTextCellEditorLocator(source);
- }
- }
-
- /**
- * @generated
- */
- static private class MultilineCellEditorLocator implements CellEditorLocator {
-
- /**
- * @generated
- */
- private IMultilineEditableFigure multilineEditableFigure;
-
- /**
- * @generated
- */
- public MultilineCellEditorLocator(IMultilineEditableFigure figure) {
- this.multilineEditableFigure = figure;
- }
-
- /**
- * @generated
- */
- public IMultilineEditableFigure getMultilineEditableFigure() {
- return multilineEditableFigure;
- }
-
- /**
- * @generated
- */
- public void relocate(CellEditor celleditor) {
- Text text = (Text) celleditor.getControl();
- Rectangle rect = getMultilineEditableFigure().getBounds().getCopy();
- rect.x = getMultilineEditableFigure().getEditionLocation().x;
- rect.y = getMultilineEditableFigure().getEditionLocation().y;
- getMultilineEditableFigure().translateToAbsolute(rect);
- if (getMultilineEditableFigure().getText().length() > 0) {
- rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT)));
- }
- if (!rect.equals(new Rectangle(text.getBounds()))) {
- text.setBounds(rect.x, rect.y, rect.width, rect.height);
- }
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
+
+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.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.locator.CellEditorLocatorAccess;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @generated
+ */
+public class UMLEditPartFactory implements EditPartFactory {
+
+ /**
+ * @generated
+ */
+ public EditPart createEditPart(EditPart context, Object model) {
+ if (model instanceof View) {
+ View view = (View) model;
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case ProfileDiagramEditPart.VISUAL_ID:
+ return new ProfileDiagramEditPart(view);
+ case DependencyNodeEditPart.VISUAL_ID:
+ return new DependencyNodeEditPart(view);
+ case MultiDependencyLabelEditPart.VISUAL_ID:
+ return new MultiDependencyLabelEditPart(view);
+ case AssociationNodeEditPart.VISUAL_ID:
+ return new AssociationNodeEditPart(view);
+ case StereotypeEditPart.VISUAL_ID:
+ return new StereotypeEditPart(view);
+ case StereotypeNameEditPart.VISUAL_ID:
+ return new StereotypeNameEditPart(view);
+ case ClassEditPart.VISUAL_ID:
+ return new ClassEditPart(view);
+ case ClassNameEditPart.VISUAL_ID:
+ return new ClassNameEditPart(view);
+ case MetaclassEditPart.VISUAL_ID:
+ return new MetaclassEditPart(view);
+ case MetaclassNameEditPart.VISUAL_ID:
+ return new MetaclassNameEditPart(view);
+ case CommentEditPart.VISUAL_ID:
+ return new CommentEditPart(view);
+ case CommentBodyEditPart.VISUAL_ID:
+ return new CommentBodyEditPart(view);
+ case ConstraintEditPart.VISUAL_ID:
+ return new ConstraintEditPart(view);
+ case ConstraintNameEditPart.VISUAL_ID:
+ return new ConstraintNameEditPart(view);
+ case ConstraintBodyEditPart.VISUAL_ID:
+ return new ConstraintBodyEditPart(view);
+ case ModelEditPartTN.VISUAL_ID:
+ return new ModelEditPartTN(view);
+ case ModelNameEditPart.VISUAL_ID:
+ return new ModelNameEditPart(view);
+ case ProfileEditPartTN.VISUAL_ID:
+ return new ProfileEditPartTN(view);
+ case ProfileNameEditPartTN.VISUAL_ID:
+ return new ProfileNameEditPartTN(view);
+ case PackageEditPart.VISUAL_ID:
+ return new PackageEditPart(view);
+ case PackageNameEditPart.VISUAL_ID:
+ return new PackageNameEditPart(view);
+ case EnumerationEditPart.VISUAL_ID:
+ return new EnumerationEditPart(view);
+ case EnumerationNameEditPart.VISUAL_ID:
+ return new EnumerationNameEditPart(view);
+ case PrimitiveTypeEditPart.VISUAL_ID:
+ return new PrimitiveTypeEditPart(view);
+ case PrimitiveTypeNameEditPart.VISUAL_ID:
+ return new PrimitiveTypeNameEditPart(view);
+ case DataTypeEditPart.VISUAL_ID:
+ return new DataTypeEditPart(view);
+ case DataTypeNameEditPart.VISUAL_ID:
+ return new DataTypeNameEditPart(view);
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ return new ShortCutDiagramEditPart(view);
+ case DiagramNameEditPart.VISUAL_ID:
+ return new DiagramNameEditPart(view);
+ case PrimitiveTypeEditPartCN.VISUAL_ID:
+ return new PrimitiveTypeEditPartCN(view);
+ case PrimitiveTypeNameEditPartCN.VISUAL_ID:
+ return new PrimitiveTypeNameEditPartCN(view);
+ case DataTypeOperationEditPart.VISUAL_ID:
+ return new DataTypeOperationEditPart(view);
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ return new EnumerationLiteralEditPart(view);
+ case DataTypePropertyEditPart.VISUAL_ID:
+ return new DataTypePropertyEditPart(view);
+ case ClassPropertyEditPart.VISUAL_ID:
+ return new ClassPropertyEditPart(view);
+ case ClassOperationEditPart.VISUAL_ID:
+ return new ClassOperationEditPart(view);
+ case StereotypeEditPartCN.VISUAL_ID:
+ return new StereotypeEditPartCN(view);
+ case StereotypeNameEditPartCN.VISUAL_ID:
+ return new StereotypeNameEditPartCN(view);
+ case ClassEditPartCN.VISUAL_ID:
+ return new ClassEditPartCN(view);
+ case ClassNameEditPartCN.VISUAL_ID:
+ return new ClassNameEditPartCN(view);
+ case MetaclassEditPartCN.VISUAL_ID:
+ return new MetaclassEditPartCN(view);
+ case MetaclassNameEditPartCN.VISUAL_ID:
+ return new MetaclassNameEditPartCN(view);
+ case CommentEditPartCN.VISUAL_ID:
+ return new CommentEditPartCN(view);
+ case CommentBodyEditPartCN.VISUAL_ID:
+ return new CommentBodyEditPartCN(view);
+ case ModelEditPartCN.VISUAL_ID:
+ return new ModelEditPartCN(view);
+ case ModelNameEditPartCN.VISUAL_ID:
+ return new ModelNameEditPartCN(view);
+ case ProfileEditPartCN.VISUAL_ID:
+ return new ProfileEditPartCN(view);
+ case ProfileNameEditPartCN.VISUAL_ID:
+ return new ProfileNameEditPartCN(view);
+ case PackageEditPartCN.VISUAL_ID:
+ return new PackageEditPartCN(view);
+ case PackageNameEditPartCN.VISUAL_ID:
+ return new PackageNameEditPartCN(view);
+ case ConstraintEditPartCN.VISUAL_ID:
+ return new ConstraintEditPartCN(view);
+ case ConstraintNameEditPartCN.VISUAL_ID:
+ return new ConstraintNameEditPartCN(view);
+ case ConstraintBodyEditPartCN.VISUAL_ID:
+ return new ConstraintBodyEditPartCN(view);
+ case EnumerationEditPartCN.VISUAL_ID:
+ return new EnumerationEditPartCN(view);
+ case EnumerationNameEditPartCN.VISUAL_ID:
+ return new EnumerationNameEditPartCN(view);
+ case DataTypeEditPartCN.VISUAL_ID:
+ return new DataTypeEditPartCN(view);
+ case DataTypeNameEditPartCN.VISUAL_ID:
+ return new DataTypeNameEditPartCN(view);
+ case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
+ return new PackagePackageableElementCompartmentEditPart(view);
+ case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ return new PackagePackageableElementCompartmentEditPartCN(view);
+ case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
+ return new ProfilePackageableElementCompartmentEditPartTN(view);
+ case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ return new ProfilePackageableElementCompartmentEditPartCN(view);
+ case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
+ return new StereotypeAttributeCompartmentEditPart(view);
+ case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ return new StereotypeAttributeCompartmentEditPartCN(view);
+ case StereotypeOperationCompartmentEditPart.VISUAL_ID:
+ return new StereotypeOperationCompartmentEditPart(view);
+ case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
+ return new StereotypeOperationCompartmentEditPartCN(view);
+ case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
+ return new ModelPackageableElementCompartmentEditPartTN(view);
+ case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
+ return new ModelPackageableElementCompartmentEditPartCN(view);
+ case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
+ return new EnumerationEnumerationLiteralCompartmentEditPartCN(view);
+ case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
+ return new EnumerationEnumerationLiteralCompartmentEditPart(view);
+ case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
+ return new DataTypeAttributeCompartmentEditPart(view);
+ case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ return new DataTypeAttributeCompartmentEditPartCN(view);
+ case DataTypeOperationCompartmentEditPart.VISUAL_ID:
+ return new DataTypeOperationCompartmentEditPart(view);
+ case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
+ return new DataTypeOperationCompartmentEditPartCN(view);
+ case ClassAttributeCompartmentEditPart.VISUAL_ID:
+ return new ClassAttributeCompartmentEditPart(view);
+ case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
+ return new ClassAttributeCompartmentEditPartCN(view);
+ case ClassOperationCompartmentEditPart.VISUAL_ID:
+ return new ClassOperationCompartmentEditPart(view);
+ case ClassOperationCompartmentEditPartCN.VISUAL_ID:
+ return new ClassOperationCompartmentEditPartCN(view);
+ case ExtensionEditPart.VISUAL_ID:
+ return new ExtensionEditPart(view);
+ case AssociationEditPart.VISUAL_ID:
+ return new AssociationEditPart(view);
+ case AssociationAppliedStereotypeEditPart.VISUAL_ID:
+ return new AssociationAppliedStereotypeEditPart(view);
+ case AssociationNameEditPart.VISUAL_ID:
+ return new AssociationNameEditPart(view);
+ case AssociationRoleTargetEditPart.VISUAL_ID:
+ return new AssociationRoleTargetEditPart(view);
+ case AssociationRoleSourceEditPart.VISUAL_ID:
+ return new AssociationRoleSourceEditPart(view);
+ case AssociationMultiplicitySourceEditPart.VISUAL_ID:
+ return new AssociationMultiplicitySourceEditPart(view);
+ case AssociationMultiplicityTargetEditPart.VISUAL_ID:
+ return new AssociationMultiplicityTargetEditPart(view);
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return new ProfileApplicationEditPart(view);
+ case AssociationBranchEditPart.VISUAL_ID:
+ return new AssociationBranchEditPart(view);
+ case AssociationBranchRoleEditPart.VISUAL_ID:
+ return new AssociationBranchRoleEditPart(view);
+ case AssociationBranchMultiplicityEditPart.VISUAL_ID:
+ return new AssociationBranchMultiplicityEditPart(view);
+ case GeneralizationEditPart.VISUAL_ID:
+ return new GeneralizationEditPart(view);
+ case GeneralizationAppliedStereotypeEditPart.VISUAL_ID:
+ return new GeneralizationAppliedStereotypeEditPart(view);
+ case DependencyEditPart.VISUAL_ID:
+ return new DependencyEditPart(view);
+ case DependencyNameEditPart.VISUAL_ID:
+ return new DependencyNameEditPart(view);
+ case DependencyAppliedStereotypeEditPart.VISUAL_ID:
+ return new DependencyAppliedStereotypeEditPart(view);
+ case DependencyBranchEditPart.VISUAL_ID:
+ return new DependencyBranchEditPart(view);
+ case ElementImportEditPart.VISUAL_ID:
+ return new ElementImportEditPart(view);
+ case ElementImportAliasEditPart.VISUAL_ID:
+ return new ElementImportAliasEditPart(view);
+ case AppliedStereotypeElementImportEditPart.VISUAL_ID:
+ return new AppliedStereotypeElementImportEditPart(view);
+ case PackageImportEditPart.VISUAL_ID:
+ return new PackageImportEditPart(view);
+ case PackageImportAppliedStereotypeEditPart.VISUAL_ID:
+ return new PackageImportAppliedStereotypeEditPart(view);
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return new CommentAnnotatedElementEditPart(view);
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return new ConstraintConstrainedElementEditPart(view);
+ case ContextLinkEditPart.VISUAL_ID:
+ return new ContextLinkEditPart(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 IMultilineEditableFigure) {
+ return new MultilineCellEditorLocator(
+ (IMultilineEditableFigure) source.getFigure());
+ }
+ else {
+ return CellEditorLocatorAccess.INSTANCE.getTextCellEditorLocator(source);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ static private class MultilineCellEditorLocator implements CellEditorLocator {
+
+ /**
+ * @generated
+ */
+ private IMultilineEditableFigure multilineEditableFigure;
+
+ /**
+ * @generated
+ */
+ public MultilineCellEditorLocator(IMultilineEditableFigure figure) {
+ this.multilineEditableFigure = figure;
+ }
+
+ /**
+ * @generated
+ */
+ public IMultilineEditableFigure getMultilineEditableFigure() {
+ return multilineEditableFigure;
+ }
+
+ /**
+ * @generated
+ */
+ public void relocate(CellEditor celleditor) {
+ Text text = (Text) celleditor.getControl();
+ Rectangle rect = getMultilineEditableFigure().getBounds().getCopy();
+ rect.x = getMultilineEditableFigure().getEditionLocation().x;
+ rect.y = getMultilineEditableFigure().getEditionLocation().y;
+ getMultilineEditableFigure().translateToAbsolute(rect);
+ if (getMultilineEditableFigure().getText().length() > 0) {
+ rect.setSize(new Dimension(text.computeSize(rect.width,
+ SWT.DEFAULT)));
+ }
+ if (!rect.equals(new Rectangle(text.getBounds()))) {
+ text.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationBranchItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationBranchItemSemanticEditPolicy.java
index 8e87c8b6cea..c46f460c498 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationBranchItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationBranchItemSemanticEditPolicy.java
@@ -1,296 +1,313 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class AssociationBranchItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public AssociationBranchItemSemanticEditPolicy() {
- super(UMLElementTypes.Association_4019);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- return getGEFWrapper(cmd.reduce());
- // return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class AssociationBranchItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public AssociationBranchItemSemanticEditPolicy() {
+ super(UMLElementTypes.Association_4019);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ return getGEFWrapper(cmd.reduce());
+ //return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationItemSemanticEditPolicy.java
index 07926c9df7a..2e6f3a9ea64 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationItemSemanticEditPolicy.java
@@ -1,296 +1,313 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class AssociationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public AssociationItemSemanticEditPolicy() {
- super(UMLElementTypes.Association_4001);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- return getGEFWrapper(cmd.reduce());
- // return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class AssociationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public AssociationItemSemanticEditPolicy() {
+ super(UMLElementTypes.Association_4001);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ return getGEFWrapper(cmd.reduce());
+ //return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationNodeItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationNodeItemSemanticEditPolicy.java
index 32ac4fea3ef..d7f6bcd0e35 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationNodeItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/AssociationNodeItemSemanticEditPolicy.java
@@ -1,306 +1,323 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class AssociationNodeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public AssociationNodeItemSemanticEditPolicy() {
- super(UMLElementTypes.Association_2015);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class AssociationNodeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public AssociationNodeItemSemanticEditPolicy() {
+ super(UMLElementTypes.Association_2015);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassItemSemanticEditPolicyCN.java
index c117da0a844..6bd9378815c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassItemSemanticEditPolicyCN.java
@@ -1,377 +1,395 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ClassItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ClassItemSemanticEditPolicyCN() {
- super(UMLElementTypes.Class_3010);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case ClassPropertyEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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;
- case ClassOperationCompartmentEditPartCN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case ClassOperationEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ExtensionCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ExtensionEditPart.VISUAL_ID:
- return getGEFWrapper(new ExtensionReorientCommand(req));
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ClassItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ClassItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.Class_3010);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case ClassPropertyEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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;
+ case ClassOperationCompartmentEditPartCN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case ClassOperationEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ExtensionCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ExtensionEditPart.VISUAL_ID:
+ return getGEFWrapper(new ExtensionReorientCommand(req));
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassOperationItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassOperationItemSemanticEditPolicy.java
index 8825bd90816..dc479397b0d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassOperationItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassOperationItemSemanticEditPolicy.java
@@ -1,61 +1,61 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ClassOperationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ClassOperationItemSemanticEditPolicy() {
- super(UMLElementTypes.Operation_3020);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ClassOperationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ClassOperationItemSemanticEditPolicy() {
+ super(UMLElementTypes.Operation_3020);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassPropertyItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassPropertyItemSemanticEditPolicy.java
index 4cd4f2ca5a7..4432a3db8e2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassPropertyItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClassPropertyItemSemanticEditPolicy.java
@@ -1,61 +1,61 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ClassPropertyItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ClassPropertyItemSemanticEditPolicy() {
- super(UMLElementTypes.Property_3002);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ClassPropertyItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ClassPropertyItemSemanticEditPolicy() {
+ super(UMLElementTypes.Property_3002);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClasseItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClasseItemSemanticEditPolicy.java
index da01ac5798e..dc44897e334 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClasseItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ClasseItemSemanticEditPolicy.java
@@ -1,377 +1,395 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ClasseItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ClasseItemSemanticEditPolicy() {
- super(UMLElementTypes.Class_2008);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case ClassOperationCompartmentEditPart.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case ClassOperationEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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;
- case ClassAttributeCompartmentEditPart.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case ClassPropertyEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ExtensionCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ExtensionEditPart.VISUAL_ID:
- return getGEFWrapper(new ExtensionReorientCommand(req));
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ClasseItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ClasseItemSemanticEditPolicy() {
+ super(UMLElementTypes.Class_2008);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case ClassOperationCompartmentEditPart.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case ClassOperationEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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;
+ case ClassAttributeCompartmentEditPart.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case ClassPropertyEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ExtensionCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ExtensionEditPart.VISUAL_ID:
+ return getGEFWrapper(new ExtensionReorientCommand(req));
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/CommentEditPartItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/CommentEditPartItemSemanticEditPolicy.java
index b5cbca3f39f..1e80b586dbf 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/CommentEditPartItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/CommentEditPartItemSemanticEditPolicy.java
@@ -1,165 +1,169 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class CommentEditPartItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public CommentEditPartItemSemanticEditPolicy() {
- super(UMLElementTypes.Comment_1002);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class CommentEditPartItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public CommentEditPartItemSemanticEditPolicy() {
+ super(UMLElementTypes.Comment_1002);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/CommentItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/CommentItemSemanticEditPolicyCN.java
index 72e33c5dcab..d3e9ad3bd2d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/CommentItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/CommentItemSemanticEditPolicyCN.java
@@ -1,165 +1,169 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class CommentItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public CommentItemSemanticEditPolicyCN() {
- super(UMLElementTypes.Comment_1007);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class CommentItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public CommentItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.Comment_1007);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ConstraintItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ConstraintItemSemanticEditPolicy.java
index a75472b30c8..89ac3bf8f06 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ConstraintItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ConstraintItemSemanticEditPolicy.java
@@ -1,241 +1,251 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ConstraintItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ConstraintItemSemanticEditPolicy() {
- super(UMLElementTypes.Constraint_1014);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ConstraintItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ConstraintItemSemanticEditPolicy() {
+ super(UMLElementTypes.Constraint_1014);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ConstraintItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ConstraintItemSemanticEditPolicyCN.java
index 270133223ee..c7b4bb469c3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ConstraintItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ConstraintItemSemanticEditPolicyCN.java
@@ -1,241 +1,251 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ConstraintItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ConstraintItemSemanticEditPolicyCN() {
- super(UMLElementTypes.Constraint_1028);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ConstraintItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ConstraintItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.Constraint_1028);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeItemSemanticEditPolicy.java
index 517b705b4e2..1fc886b8761 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeItemSemanticEditPolicy.java
@@ -1,363 +1,380 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class DataTypeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public DataTypeItemSemanticEditPolicy() {
- super(UMLElementTypes.DataType_2010);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case DataTypePropertyEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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;
- case DataTypeOperationCompartmentEditPart.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case DataTypeOperationEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class DataTypeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public DataTypeItemSemanticEditPolicy() {
+ super(UMLElementTypes.DataType_2010);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case DataTypePropertyEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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;
+ case DataTypeOperationCompartmentEditPart.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case DataTypeOperationEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeItemSemanticEditPolicyCN.java
index 38cf8662683..e2e43828139 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeItemSemanticEditPolicyCN.java
@@ -1,363 +1,380 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class DataTypeItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public DataTypeItemSemanticEditPolicyCN() {
- super(UMLElementTypes.DataType_3027);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case DataTypePropertyEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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;
- case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case DataTypeOperationEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class DataTypeItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public DataTypeItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.DataType_3027);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case DataTypePropertyEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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;
+ case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case DataTypeOperationEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeOperationItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeOperationItemSemanticEditPolicy.java
index 92211595ce2..73df3df76c2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeOperationItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypeOperationItemSemanticEditPolicy.java
@@ -1,61 +1,61 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class DataTypeOperationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public DataTypeOperationItemSemanticEditPolicy() {
- super(UMLElementTypes.Operation_3019);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class DataTypeOperationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public DataTypeOperationItemSemanticEditPolicy() {
+ super(UMLElementTypes.Operation_3019);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypePropertyItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypePropertyItemSemanticEditPolicy.java
index a4dcade8517..48e0baf494c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypePropertyItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DataTypePropertyItemSemanticEditPolicy.java
@@ -1,61 +1,61 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class DataTypePropertyItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public DataTypePropertyItemSemanticEditPolicy() {
- super(UMLElementTypes.Property_3018);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class DataTypePropertyItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public DataTypePropertyItemSemanticEditPolicy() {
+ super(UMLElementTypes.Property_3018);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyBranchItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyBranchItemSemanticEditPolicy.java
index 09e4057854d..d1666b2f410 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyBranchItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyBranchItemSemanticEditPolicy.java
@@ -1,214 +1,222 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class DependencyBranchItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public DependencyBranchItemSemanticEditPolicy() {
- super(UMLElementTypes.Dependency_4018);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- return getGEFWrapper(cmd.reduce());
- // return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class DependencyBranchItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public DependencyBranchItemSemanticEditPolicy() {
+ super(UMLElementTypes.Dependency_4018);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ return getGEFWrapper(cmd.reduce());
+ //return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyItemSemanticEditPolicy.java
index 455523631e2..84e62417e2d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyItemSemanticEditPolicy.java
@@ -1,214 +1,222 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class DependencyItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public DependencyItemSemanticEditPolicy() {
- super(UMLElementTypes.Dependency_4008);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- return getGEFWrapper(cmd.reduce());
- // return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class DependencyItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public DependencyItemSemanticEditPolicy() {
+ super(UMLElementTypes.Dependency_4008);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ return getGEFWrapper(cmd.reduce());
+ //return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyNodeItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyNodeItemSemanticEditPolicy.java
index ec9240dfaae..cd875438450 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyNodeItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/DependencyNodeItemSemanticEditPolicy.java
@@ -1,224 +1,232 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class DependencyNodeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public DependencyNodeItemSemanticEditPolicy() {
- super(UMLElementTypes.Dependency_2014);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class DependencyNodeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public DependencyNodeItemSemanticEditPolicy() {
+ super(UMLElementTypes.Dependency_2014);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ElementImportItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ElementImportItemSemanticEditPolicy.java
index 2fc7b869c6e..6108b1150d5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ElementImportItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ElementImportItemSemanticEditPolicy.java
@@ -1,149 +1,152 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ElementImportItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ElementImportItemSemanticEditPolicy() {
- super(UMLElementTypes.ElementImport_1064);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- return getGEFWrapper(cmd.reduce());
- // return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ElementImportItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ElementImportItemSemanticEditPolicy() {
+ super(UMLElementTypes.ElementImport_1064);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ return getGEFWrapper(cmd.reduce());
+ //return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationItemSemanticEditPolicy.java
index 42513ef085b..039a8678e6c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationItemSemanticEditPolicy.java
@@ -1,344 +1,361 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class EnumerationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public EnumerationItemSemanticEditPolicy() {
- super(UMLElementTypes.Enumeration_2006);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case EnumerationLiteralEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class EnumerationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public EnumerationItemSemanticEditPolicy() {
+ super(UMLElementTypes.Enumeration_2006);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationItemSemanticEditPolicyCN.java
index 66bd4fc1756..e4b127e60e2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationItemSemanticEditPolicyCN.java
@@ -1,344 +1,361 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class EnumerationItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public EnumerationItemSemanticEditPolicyCN() {
- super(UMLElementTypes.Enumeration_3025);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case EnumerationLiteralEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class EnumerationItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public EnumerationItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.Enumeration_3025);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationLiteralItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationLiteralItemSemanticEditPolicy.java
index fc598feed7c..27acd6298fe 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationLiteralItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/EnumerationLiteralItemSemanticEditPolicy.java
@@ -1,61 +1,61 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class EnumerationLiteralItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public EnumerationLiteralItemSemanticEditPolicy() {
- super(UMLElementTypes.EnumerationLiteral_1037);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class EnumerationLiteralItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public EnumerationLiteralItemSemanticEditPolicy() {
+ super(UMLElementTypes.EnumerationLiteral_1037);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ExtensionItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ExtensionItemSemanticEditPolicy.java
index 15b2626e764..d5f2bb65afa 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ExtensionItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ExtensionItemSemanticEditPolicy.java
@@ -1,296 +1,313 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ExtensionItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ExtensionItemSemanticEditPolicy() {
- super(UMLElementTypes.Extension_1013);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- return getGEFWrapper(cmd.reduce());
- // return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ExtensionItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ExtensionItemSemanticEditPolicy() {
+ super(UMLElementTypes.Extension_1013);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ return getGEFWrapper(cmd.reduce());
+ //return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/GeneralizationItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/GeneralizationItemSemanticEditPolicy.java
index 71cf0f46358..47a557ac552 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/GeneralizationItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/GeneralizationItemSemanticEditPolicy.java
@@ -1,149 +1,152 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class GeneralizationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public GeneralizationItemSemanticEditPolicy() {
- super(UMLElementTypes.Generalization_4002);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- return getGEFWrapper(cmd.reduce());
- // return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class GeneralizationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public GeneralizationItemSemanticEditPolicy() {
+ super(UMLElementTypes.Generalization_4002);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ return getGEFWrapper(cmd.reduce());
+ //return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/MetaclassItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/MetaclassItemSemanticEditPolicy.java
index 8933f150b5a..e0d5505ed75 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/MetaclassItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/MetaclassItemSemanticEditPolicy.java
@@ -1,320 +1,338 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class MetaclassItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public MetaclassItemSemanticEditPolicy() {
- super(UMLElementTypes.Class_1031);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ExtensionCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ExtensionEditPart.VISUAL_ID:
- return getGEFWrapper(new ExtensionReorientCommand(req));
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class MetaclassItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public MetaclassItemSemanticEditPolicy() {
+ super(UMLElementTypes.Class_1031);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ExtensionCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ExtensionEditPart.VISUAL_ID:
+ return getGEFWrapper(new ExtensionReorientCommand(req));
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/MetaclassItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/MetaclassItemSemanticEditPolicyCN.java
index 0dbf35f45dc..92270c2acbe 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/MetaclassItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/MetaclassItemSemanticEditPolicyCN.java
@@ -1,320 +1,338 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class MetaclassItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public MetaclassItemSemanticEditPolicyCN() {
- super(UMLElementTypes.Class_3028);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ExtensionCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ExtensionEditPart.VISUAL_ID:
- return getGEFWrapper(new ExtensionReorientCommand(req));
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class MetaclassItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public MetaclassItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.Class_3028);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ExtensionCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ExtensionEditPart.VISUAL_ID:
+ return getGEFWrapper(new ExtensionReorientCommand(req));
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ModelItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ModelItemSemanticEditPolicyCN.java
index 34e67c23221..9b20dd9e1b8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ModelItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ModelItemSemanticEditPolicyCN.java
@@ -1,538 +1,551 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ModelItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ModelItemSemanticEditPolicyCN() {
- super(UMLElementTypes.Model_1027);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case CommentEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ModelEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ProfileEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ProfileApplicationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PackageEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ConstraintEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 EnumerationEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PrimitiveTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 DataTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ClassEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ProfileApplicationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ProfileApplicationEditPart.VISUAL_ID:
- return getGEFWrapper(new ProfileApplicationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ModelItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ModelItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.Model_1027);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case CommentEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ModelEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ProfileEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ProfileApplicationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PackageEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ConstraintEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 EnumerationEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PrimitiveTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 DataTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ClassEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ProfileApplicationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return getGEFWrapper(new ProfileApplicationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ModelItemSemanticEditPolicyTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ModelItemSemanticEditPolicyTN.java
index be6fc1617d1..65707b3db39 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ModelItemSemanticEditPolicyTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ModelItemSemanticEditPolicyTN.java
@@ -1,538 +1,551 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ModelItemSemanticEditPolicyTN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ModelItemSemanticEditPolicyTN() {
- super(UMLElementTypes.Model_2005);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case CommentEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ModelEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ProfileEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ProfileApplicationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PackageEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ConstraintEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 EnumerationEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PrimitiveTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 DataTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ClassEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ProfileApplicationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ProfileApplicationEditPart.VISUAL_ID:
- return getGEFWrapper(new ProfileApplicationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ModelItemSemanticEditPolicyTN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ModelItemSemanticEditPolicyTN() {
+ super(UMLElementTypes.Model_2005);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case CommentEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ModelEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ProfileEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ProfileApplicationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PackageEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ConstraintEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 EnumerationEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PrimitiveTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 DataTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ClassEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ProfileApplicationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return getGEFWrapper(new ProfileApplicationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageImportItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageImportItemSemanticEditPolicy.java
index 4b097588923..3eeeec1d3c7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageImportItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageImportItemSemanticEditPolicy.java
@@ -1,149 +1,152 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class PackageImportItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public PackageImportItemSemanticEditPolicy() {
- super(UMLElementTypes.PackageImport_1065);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- return getGEFWrapper(cmd.reduce());
- // return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class PackageImportItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public PackageImportItemSemanticEditPolicy() {
+ super(UMLElementTypes.PackageImport_1065);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ return getGEFWrapper(cmd.reduce());
+ //return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageItemSemanticEditPolicy.java
index b08be6d3b66..3fab3d641b4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageItemSemanticEditPolicy.java
@@ -1,567 +1,580 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class PackageItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public PackageItemSemanticEditPolicy() {
- super(UMLElementTypes.Package_2007);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case CommentEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ModelEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ProfileEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ProfileApplicationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PackageEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ConstraintEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 EnumerationEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PrimitiveTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 DataTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 StereotypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ClassEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ProfileApplicationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ProfileApplicationEditPart.VISUAL_ID:
- return getGEFWrapper(new ProfileApplicationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class PackageItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public PackageItemSemanticEditPolicy() {
+ super(UMLElementTypes.Package_2007);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case CommentEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ModelEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ProfileEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ProfileApplicationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PackageEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ConstraintEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 EnumerationEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PrimitiveTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 DataTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 StereotypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ClassEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ProfileApplicationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return getGEFWrapper(new ProfileApplicationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageItemSemanticEditPolicyCN.java
index 5ac9cf795be..1d7ecbb0dfa 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PackageItemSemanticEditPolicyCN.java
@@ -1,610 +1,623 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageCreateCommandCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class PackageItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public PackageItemSemanticEditPolicyCN() {
- super(UMLElementTypes.Package_1012);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getCreateCommand(CreateElementRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return super.getCreateCommand(req);
- }
- if (UMLElementTypes.Package_1012 == requestElementType) {
- return getGEFWrapper(new PackageCreateCommandCN(req, DiagramUtils.getDiagramFrom(getHost())));
- }
- return super.getCreateCommand(req);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case PackageEditPartCN.VISUAL_ID:
- for (Iterator<?> it = node.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), node.getElement(), false))); // directlyOwned: true
- // don't need explicit deletion of node as parent's view deletion would clean child views as well
- // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), node));
- break;
- case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case CommentEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ModelEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ProfileEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ProfileApplicationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PackageEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ConstraintEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 EnumerationEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PrimitiveTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 DataTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 StereotypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ClassEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ProfileApplicationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ProfileApplicationEditPart.VISUAL_ID:
- return getGEFWrapper(new ProfileApplicationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageCreateCommandCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class PackageItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public PackageItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.Package_1012);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getCreateCommand(CreateElementRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return super.getCreateCommand(req);
+ }
+ if (UMLElementTypes.Package_1012 == requestElementType) {
+ return getGEFWrapper(new PackageCreateCommandCN(req, DiagramUtils.getDiagramFrom(getHost())));
+ }
+ return super.getCreateCommand(req);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case PackageEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = node.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), node.getElement(), false))); // directlyOwned: true
+ // don't need explicit deletion of node as parent's view deletion would clean child views as well
+ // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), node));
+ break;
+ case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case CommentEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ModelEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ProfileEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ProfileApplicationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PackageEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ConstraintEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 EnumerationEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PrimitiveTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 DataTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 StereotypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ClassEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ProfileApplicationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return getGEFWrapper(new ProfileApplicationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PrimitiveTypeItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PrimitiveTypeItemSemanticEditPolicy.java
index d29f2394f75..2b5d53ca577 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PrimitiveTypeItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PrimitiveTypeItemSemanticEditPolicy.java
@@ -1,306 +1,323 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class PrimitiveTypeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public PrimitiveTypeItemSemanticEditPolicy() {
- super(UMLElementTypes.PrimitiveType_2009);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class PrimitiveTypeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public PrimitiveTypeItemSemanticEditPolicy() {
+ super(UMLElementTypes.PrimitiveType_2009);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PrimitiveTypeItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PrimitiveTypeItemSemanticEditPolicyCN.java
index 068bbc77fb8..7b5dd05dbe2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PrimitiveTypeItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/PrimitiveTypeItemSemanticEditPolicyCN.java
@@ -1,306 +1,323 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class PrimitiveTypeItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public PrimitiveTypeItemSemanticEditPolicyCN() {
- super(UMLElementTypes.PrimitiveType_3026);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class PrimitiveTypeItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public PrimitiveTypeItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.PrimitiveType_3026);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileApplicationItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileApplicationItemSemanticEditPolicy.java
index ad699ecb913..42e1c766fac 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileApplicationItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileApplicationItemSemanticEditPolicy.java
@@ -1,149 +1,152 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ProfileApplicationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ProfileApplicationItemSemanticEditPolicy() {
- super(UMLElementTypes.ProfileApplication_1045);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- return getGEFWrapper(cmd.reduce());
- // return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- }
-
- /**
- * @generated
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ProfileApplicationItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ProfileApplicationItemSemanticEditPolicy() {
+ super(UMLElementTypes.ProfileApplication_1045);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ return getGEFWrapper(cmd.reduce());
+ //return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileItemSemanticEditPolicyCN.java
index 6ebd280cf18..98eb52ac704 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileItemSemanticEditPolicyCN.java
@@ -1,599 +1,613 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ProfileItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ProfileItemSemanticEditPolicyCN() {
- super(UMLElementTypes.Profile_1024);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case StereotypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ModelEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ProfileEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ProfileApplicationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PackageEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ConstraintEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 EnumerationEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PrimitiveTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 DataTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 CommentEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 MetaclassEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ClassEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ProfileApplicationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ProfileApplicationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ProfileApplicationEditPart.VISUAL_ID:
- return getGEFWrapper(new ProfileApplicationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ProfileItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ProfileItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.Profile_1024);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case StereotypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ModelEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ProfileEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ProfileApplicationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PackageEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ConstraintEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 EnumerationEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PrimitiveTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 DataTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 CommentEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 MetaclassEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ClassEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ProfileApplicationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ProfileApplicationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return getGEFWrapper(new ProfileApplicationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileItemSemanticEditPolicyTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileItemSemanticEditPolicyTN.java
index 0e3a7a3ffa5..a0128b59fee 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileItemSemanticEditPolicyTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ProfileItemSemanticEditPolicyTN.java
@@ -1,599 +1,613 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ProfileItemSemanticEditPolicyTN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ProfileItemSemanticEditPolicyTN() {
- super(UMLElementTypes.Profile_1030);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case StereotypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ModelEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ProfileEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ProfileApplicationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PackageEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- case PackageImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ConstraintEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 EnumerationEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 PrimitiveTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 DataTypeEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 CommentEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 MetaclassEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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 ClassEditPartCN.VISUAL_ID:
- for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
- Edge incomingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- case ContextLinkEditPart.VISUAL_ID:
- DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- case ExtensionEditPart.VISUAL_ID:
- case AssociationEditPart.VISUAL_ID:
- case AssociationBranchEditPart.VISUAL_ID:
- case GeneralizationEditPart.VISUAL_ID:
- case DependencyEditPart.VISUAL_ID:
- case DependencyBranchEditPart.VISUAL_ID:
- case ElementImportEditPart.VISUAL_ID:
- DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ProfileApplicationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ProfileApplicationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ProfileApplicationEditPart.VISUAL_ID:
- return getGEFWrapper(new ProfileApplicationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ProfileApplicationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ProfileItemSemanticEditPolicyTN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ProfileItemSemanticEditPolicyTN() {
+ super(UMLElementTypes.Profile_1030);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case StereotypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ModelEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ProfileEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ProfileApplicationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PackageEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ case PackageImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ConstraintEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 EnumerationEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 PrimitiveTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 DataTypeEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 CommentEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 MetaclassEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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 ClassEditPartCN.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(incomingLink)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ case ContextLinkEditPart.VISUAL_ID:
+ DestroyReferenceRequest destroyRefReq = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ case ExtensionEditPart.VISUAL_ID:
+ case AssociationEditPart.VISUAL_ID:
+ case AssociationBranchEditPart.VISUAL_ID:
+ case GeneralizationEditPart.VISUAL_ID:
+ case DependencyEditPart.VISUAL_ID:
+ case DependencyBranchEditPart.VISUAL_ID:
+ case ElementImportEditPart.VISUAL_ID:
+ DestroyElementRequest destroyEltReq = new DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ProfileApplicationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.ProfileApplication_1045 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ProfileApplicationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return getGEFWrapper(new ProfileApplicationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ShortCutDiagramItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ShortCutDiagramItemSemanticEditPolicy.java
index 8133687954a..a8a3d9bedb3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ShortCutDiagramItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/ShortCutDiagramItemSemanticEditPolicy.java
@@ -1,61 +1,61 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class ShortCutDiagramItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public ShortCutDiagramItemSemanticEditPolicy() {
- super(UMLElementTypes.Diagram_2016);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ShortCutDiagramItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ShortCutDiagramItemSemanticEditPolicy() {
+ super(UMLElementTypes.Diagram_2016);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/StereotypeItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/StereotypeItemSemanticEditPolicy.java
index 60529755b33..ab458d91a6b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/StereotypeItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/StereotypeItemSemanticEditPolicy.java
@@ -1,377 +1,395 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class StereotypeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public StereotypeItemSemanticEditPolicy() {
- super(UMLElementTypes.Stereotype_1026);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case ClassPropertyEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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;
- case StereotypeOperationCompartmentEditPart.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case ClassOperationEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ExtensionCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ExtensionEditPart.VISUAL_ID:
- return getGEFWrapper(new ExtensionReorientCommand(req));
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class StereotypeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public StereotypeItemSemanticEditPolicy() {
+ super(UMLElementTypes.Stereotype_1026);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case ClassPropertyEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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;
+ case StereotypeOperationCompartmentEditPart.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case ClassOperationEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ExtensionCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ExtensionEditPart.VISUAL_ID:
+ return getGEFWrapper(new ExtensionReorientCommand(req));
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/StereotypeItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/StereotypeItemSemanticEditPolicyCN.java
index 6f2f86cc39b..173457b15eb 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/StereotypeItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/StereotypeItemSemanticEditPolicyCN.java
@@ -1,377 +1,395 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.ReorientReferenceRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-
-/**
- * @generated
- */
-public class StereotypeItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
-
- /**
- * @generated
- */
- public StereotypeItemSemanticEditPolicyCN() {
- super(UMLElementTypes.Stereotype_1023);
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- View view = (View) getHost().getModel();
- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- 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
- List<EObject> todestroy = new ArrayList<EObject>();
- todestroy.add(req.getElementToDestroy());
- // cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
- } else {
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
- }
-
- /**
- * @generated
- */
- protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
- View view = (View) getHost().getModel();
- for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- Node node = (Node) nit.next();
- switch (UMLVisualIDRegistry.getVisualID(node)) {
- case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case ClassPropertyEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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;
- case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
- for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- Node cnode = (Node) cit.next();
- switch (UMLVisualIDRegistry.getVisualID(cnode)) {
- case ClassOperationEditPart.VISUAL_ID:
- for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
- Edge outgoingLink = (Edge) it.next();
- switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
- }
- }
- 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
- */
- @Override
- 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) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- if (isExtendedType) {
- return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new PackageImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- return null;
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType == null) {
- return null;
- }
- IElementType baseElementType = requestElementType;
- boolean isExtendedType = false;
- if (requestElementType instanceof IExtendedHintedElementType) {
- baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
- if (baseElementType != null) {
- isExtendedType = true;
- } else {
- // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
- baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
- isExtendedType = true;
- }
- }
- if (UMLElementTypes.Extension_1013 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ExtensionCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4001 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Association_4019 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new AssociationBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Generalization_4002 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4008 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.Dependency_4018 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new DependencyBranchCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ElementImport_1064 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ElementImportCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.PackageImport_1065 == baseElementType) {
- return null;
- }
- if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
- }
- if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
- if (isExtendedType) {
- return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
- }
- return getGEFWrapper(new ContextLinkCreateCommand(req, req.getSource(), req.getTarget()));
- }
- 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
- */
- @Override
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- case ExtensionEditPart.VISUAL_ID:
- return getGEFWrapper(new ExtensionReorientCommand(req));
- case AssociationEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationReorientCommand(req));
- case AssociationBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new AssociationBranchReorientCommand(req));
- case GeneralizationEditPart.VISUAL_ID:
- return getGEFWrapper(new GeneralizationReorientCommand(req));
- case DependencyEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyReorientCommand(req));
- case DependencyBranchEditPart.VISUAL_ID:
- return getGEFWrapper(new DependencyBranchReorientCommand(req));
- case ElementImportEditPart.VISUAL_ID:
- return getGEFWrapper(new ElementImportReorientCommand(req));
- case PackageImportEditPart.VISUAL_ID:
- return getGEFWrapper(new PackageImportReorientCommand(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
- */
- @Override
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- switch (getVisualID(req)) {
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
- case ContextLinkEditPart.VISUAL_ID:
- return getGEFWrapper(new ContextLinkReorientCommand(req));
- }
- return super.getReorientReferenceRelationshipCommand(req);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+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.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.AssociationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ConstraintConstrainedElementReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ContextLinkReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyBranchReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.DependencyReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ElementImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.ExtensionReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.GeneralizationReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportCreateCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.commands.PackageImportReorientCommand;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class StereotypeItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public StereotypeItemSemanticEditPolicyCN() {
+ super(UMLElementTypes.Stereotype_1023);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ 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
+ List<EObject> todestroy = new ArrayList<EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
+ } else {
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case ClassPropertyEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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;
+ case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case ClassOperationEditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(outgoingLink)) {
+ }
+ }
+ 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
+ */
+ @Override
+ 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) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new PackageImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return null;
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+ if (UMLElementTypes.Extension_1013 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ExtensionCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4001 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Association_4019 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new AssociationBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Generalization_4002 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new GeneralizationCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.Dependency_4018 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new DependencyBranchCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ElementImport_1064 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ElementImportCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.PackageImport_1065 == baseElementType) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_1022 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintConstrainedElement_4014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ConstraintContext_8500 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new ContextLinkCreateCommand(req,
+ req.getSource(), req.getTarget()));
+ }
+ 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
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ExtensionEditPart.VISUAL_ID:
+ return getGEFWrapper(new ExtensionReorientCommand(req));
+ case AssociationEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationReorientCommand(req));
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new AssociationBranchReorientCommand(req));
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGEFWrapper(new GeneralizationReorientCommand(req));
+ case DependencyEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyReorientCommand(req));
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getGEFWrapper(new DependencyBranchReorientCommand(req));
+ case ElementImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementImportReorientCommand(req));
+ case PackageImportEditPart.VISUAL_ID:
+ return getGEFWrapper(new PackageImportReorientCommand(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
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req));
+ case ContextLinkEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContextLinkReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLBaseItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLBaseItemSemanticEditPolicy.java
index 24267aadd5a..d5145511418 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLBaseItemSemanticEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLBaseItemSemanticEditPolicy.java
@@ -1,769 +1,784 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand;
-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;
-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.DestroyRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
-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.emf.type.core.requests.SetRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.tooling.runtime.edit.helpers.GeneratedEditHelperBase;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.profile.utils.Util;
-import org.eclipse.uml2.uml.Association;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Dependency;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.ElementImport;
-import org.eclipse.uml2.uml.Extension;
-import org.eclipse.uml2.uml.Generalization;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PackageImport;
-import org.eclipse.uml2.uml.PackageableElement;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.ProfileApplication;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Type;
-
-/**
- * @generated
- */
-public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy {
-
- /**
- * Extended request data key to hold editpart visual id.
- *
- * @generated
- */
- public static final String VISUAL_ID_KEY = "visual_id"; //$NON-NLS-1$
-
- /**
- * Extended request data key to hold the edge view during a reconnect request.
- *
- * @generated
- */
- public static final String GRAPHICAL_RECONNECTED_EDGE = "graphical_edge"; //$NON-NLS-1$
-
- /**
- * @generated
- */
- private final IElementType myElementType;
-
- /**
- * @generated
- */
- protected UMLBaseItemSemanticEditPolicy(IElementType elementType) {
- myElementType = elementType;
- }
-
- /**
- * Extended request data key to hold editpart visual id.
- * Add visual id of edited editpart to extended data of the request
- * so command switch can decide what kind of diagram element is being edited.
- * It is done in those cases when it's not possible to deduce diagram
- * element kind from domain element.
- * Add the reoriented view to the request extended data so that the view
- * currently edited can be distinguished from other views of the same element
- * and these latter possibly removed if they become inconsistent after reconnect
- *
- * @generated
- */
- @Override
- @SuppressWarnings("unchecked")
- public Command getCommand(Request request) {
- if (request instanceof ReconnectRequest) {
- Object view = ((ReconnectRequest) request).getConnectionEditPart().getModel();
- if (view instanceof View) {
- Integer id = new Integer(UMLVisualIDRegistry.getVisualID((View) view));
- request.getExtendedData().put(VISUAL_ID_KEY, id);
- request.getExtendedData().put(GRAPHICAL_RECONNECTED_EDGE, view);
- }
- }
- return super.getCommand(request);
- }
-
- /**
- * Returns visual id from request parameters.
- *
- * @generated
- */
- protected int getVisualID(IEditCommandRequest request) {
- Object id = request.getParameter(VISUAL_ID_KEY);
- return id instanceof Integer ? ((Integer) id).intValue() : -1;
- }
-
- /**
- * @generated
- */
- @Override
- protected Command getSemanticCommand(IEditCommandRequest request) {
- IEditCommandRequest completedRequest = completeRequest(request);
- Command semanticCommand = getSemanticCommandSwitch(completedRequest);
- semanticCommand = getEditHelperCommand(completedRequest, semanticCommand);
- if (completedRequest instanceof DestroyRequest) {
- DestroyRequest destroyRequest = (DestroyRequest) completedRequest;
- return shouldProceed(destroyRequest) ? addDeleteViewCommand(semanticCommand, destroyRequest) : null;
- }
- return semanticCommand;
- }
-
- /**
- * @generated
- */
- protected Command addDeleteViewCommand(Command mainCommand, DestroyRequest completedRequest) {
- Command deleteViewCommand = getGEFWrapper(new DeleteCommand(getEditingDomain(), (View) getHost().getModel()));
- return mainCommand == null ? deleteViewCommand : mainCommand.chain(deleteViewCommand);
- }
-
- /**
- * @generated
- */
- private Command getEditHelperCommand(IEditCommandRequest request, Command editPolicyCommand) {
- if (editPolicyCommand != null) {
- ICommand command = editPolicyCommand instanceof ICommandProxy ? ((ICommandProxy) editPolicyCommand).getICommand() : new CommandProxy(editPolicyCommand);
- request.setParameter(GeneratedEditHelperBase.EDIT_POLICY_COMMAND, command);
- }
- IElementType requestContextElementType = getContextElementType(request);
- request.setParameter(GeneratedEditHelperBase.CONTEXT_ELEMENT_TYPE, requestContextElementType);
- ICommand command = requestContextElementType.getEditCommand(request);
- request.setParameter(GeneratedEditHelperBase.EDIT_POLICY_COMMAND, null);
- request.setParameter(GeneratedEditHelperBase.CONTEXT_ELEMENT_TYPE, null);
- if (command != null) {
- if (!(command instanceof CompositeTransactionalCommand)) {
- command = new CompositeTransactionalCommand(getEditingDomain(), command.getLabel()).compose(command);
- }
- return new ICommandProxy(command);
- }
- return editPolicyCommand;
- }
-
- /**
- * @generated
- */
- protected IElementType getContextElementType(IEditCommandRequest request) {
- IElementType requestContextElementType = UMLElementTypes.getElementType(getVisualID(request));
- return requestContextElementType != null ? requestContextElementType : myElementType;
- }
-
- /**
- * @generated
- */
- protected Command getSemanticCommandSwitch(IEditCommandRequest req) {
- if (req instanceof CreateRelationshipRequest) {
- return getCreateRelationshipCommand((CreateRelationshipRequest) req);
- } else if (req instanceof CreateElementRequest) {
- return getCreateCommand((CreateElementRequest) req);
- } else if (req instanceof ConfigureRequest) {
- return getConfigureCommand((ConfigureRequest) req);
- } else if (req instanceof DestroyElementRequest) {
- return getDestroyElementCommand((DestroyElementRequest) req);
- } else if (req instanceof DestroyReferenceRequest) {
- return getDestroyReferenceCommand((DestroyReferenceRequest) req);
- } else if (req instanceof DuplicateElementsRequest) {
- return getDuplicateCommand((DuplicateElementsRequest) req);
- } else if (req instanceof GetEditContextRequest) {
- return getEditContextCommand((GetEditContextRequest) req);
- } else if (req instanceof MoveRequest) {
- return getMoveCommand((MoveRequest) req);
- } else if (req instanceof ReorientReferenceRelationshipRequest) {
- return getReorientReferenceRelationshipCommand((ReorientReferenceRelationshipRequest) req);
- } else if (req instanceof ReorientRelationshipRequest) {
- return getReorientRelationshipCommand((ReorientRelationshipRequest) req);
- } else if (req instanceof SetRequest) {
- return getSetCommand((SetRequest) req);
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getConfigureCommand(ConfigureRequest req) {
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getCreateCommand(CreateElementRequest req) {
- IElementType requestElementType = req.getElementType();
- if (requestElementType instanceof IExtendedHintedElementType) {
- // try to get a semantic create command from the extended type
- IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(req.getContainer());
- if (commandProvider != null) {
- ICommand command = commandProvider.getEditCommand(req);
- if (command != null && command.canExecute()) {
- return new ICommandProxy(command);
- }
- }
- }
- return null;
- }
-
- // RS: add code for extended types
- /**
- * @generated
- */
- protected Command getExtendedTypeCreationCommand(CreateElementRequest request, IExtendedHintedElementType requestElementType) {
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(request.getContainer());
- if (provider == null) {
- return UnexecutableCommand.INSTANCE;
- }
- // Retrieve create command from the Element Edit service
- ICommand createGMFCommand = provider.getEditCommand(request);
- return getGEFWrapper(createGMFCommand);
- }
-
- /**
- * @generated
- */
- protected Command getExtendedStartCreateRelationshipCommand(CreateElementRequest request, IExtendedHintedElementType requestElementType) {
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(requestElementType);
- if (provider == null) {
- return UnexecutableCommand.INSTANCE;
- }
- // Retrieve create command from the Element Edit service
- ICommand createGMFCommand = provider.getEditCommand(request);
- return getGEFWrapper(createGMFCommand);
- }
-
- /**
- * @generated
- */
- protected Command getExtendedCompleteCreateRelationshipCommand(CreateElementRequest request, IExtendedHintedElementType requestElementType) {
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(requestElementType);
- if (provider == null) {
- return UnexecutableCommand.INSTANCE;
- }
- // Retrieve create command from the Element Edit service
- ICommand createGMFCommand = provider.getEditCommand(request);
- return getGEFWrapper(createGMFCommand);
- }
-
- // RS: End of add code for extended types
- /**
- * @generated
- */
- protected Command getSetCommand(SetRequest req) {
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getEditContextCommand(GetEditContextRequest req) {
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getDestroyElementCommand(DestroyElementRequest req) {
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) {
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getDuplicateCommand(DuplicateElementsRequest req) {
- return null;
- }
-
- /**
- * @generated
- */
- protected Command getMoveCommand(MoveRequest req) {
- EObject targetCEObject = req.getTargetContainer();
- if (targetCEObject != null) {
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(targetCEObject);
- if (provider != null) {
- ICommand moveCommand = provider.getEditCommand(req);
- if (moveCommand != null) {
- return new ICommandProxy(moveCommand);
- }
- }
- return UnexecutableCommand.INSTANCE;
- } else {
- return getGEFWrapper(new MoveElementsCommand(req));
- }
- }
-
- /**
- * @generated
- */
- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * @generated
- */
- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- return UnexecutableCommand.INSTANCE;
- }
-
- /**
- * @generated
- */
- protected final Command getGEFWrapper(ICommand cmd) {
- return new ICommandProxy(cmd);
- }
-
- /**
- * Returns editing domain from the host edit part.
- *
- * @generated
- */
- protected TransactionalEditingDomain getEditingDomain() {
- return ((IGraphicalEditPart) getHost()).getEditingDomain();
- }
-
- /**
- * Clean all shortcuts to the host element from the same diagram
- *
- * @generated
- */
- protected void addDestroyShortcutsCommand(ICompositeCommand cmd, View view) {
- assert view.getEAnnotation("Shortcut") == null; //$NON-NLS-1$
- for (Iterator<?> it = view.getDiagram().getChildren().iterator(); it.hasNext();) {
- View nextView = (View) it.next();
- if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { //$NON-NLS-1$
- continue;
- }
- cmd.add(new DeleteCommand(getEditingDomain(), nextView));
- }
- }
-
- /**
- * @generated
- */
- public static LinkConstraints getLinkConstraints() {
- LinkConstraints cached = UMLDiagramEditorPlugin.getInstance().getLinkConstraints();
- if (cached == null) {
- UMLDiagramEditorPlugin.getInstance().setLinkConstraints(cached = new LinkConstraints());
- }
- return cached;
- }
-
- /**
- * @generated
- */
- public static class LinkConstraints {
-
- /**
- * @generated
- */
- public LinkConstraints() { // use static method #getLinkConstraints() to access instance
- }
-
- /**
- * @generated
- */
- public boolean canCreateExtension_1013(Package container, Property source, Class target) {
- return canExistExtension_1013(container, null, source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreateAssociation_4001(Package container, Type source, Type target) {
- return canExistAssociation_4001(container, null, source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreateProfileApplication_1045(Package container, Package source, Profile target) {
- return canExistProfileApplication_1045(container, null, source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreateAssociation_4019(Package container, Type source, Type target) {
- return canExistAssociation_4019(container, null, source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreateGeneralization_4002(Classifier source, Classifier target) {
- return canExistGeneralization_4002(null, source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreateDependency_4008(Package container, NamedElement source, NamedElement target) {
- return canExistDependency_4008(container, null, source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreateDependency_4018(Package container, NamedElement source, NamedElement target) {
- return canExistDependency_4018(container, null, source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreateElementImport_1064(Namespace container, Namespace source, PackageableElement target) {
- return canExistElementImport_1064(container, null, source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreatePackageImport_1065(Namespace container, Namespace source, Package target) {
- return canExistPackageImport_1065(container, null, source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreateCommentAnnotatedElement_1022(Comment source, Element target) {
- if (source != null) {
- if (source.getAnnotatedElements().contains(target)) {
- return false;
- }
- }
- return canExistCommentAnnotatedElement_1022(source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreateConstraintConstrainedElement_4014(Constraint source, Element target) {
- if (source != null) {
- if (source.getConstrainedElements().contains(target)) {
- return false;
- }
- }
- return canExistConstraintConstrainedElement_4014(source, target);
- }
-
- /**
- * @generated
- */
- public boolean canCreateConstraintContext_8500(Constraint source, Namespace target) {
- if (source != null) {
- if (source.getContext() != null) {
- return false;
- }
- }
- if (target != null && (target.getOwnedRules().contains(target))) {
- return false;
- }
- return canExistConstraintContext_8500(source, target);
- }
-
- /**
- * @generated
- */
- public boolean canExistExtension_1013(Package container, Extension linkInstance, Property source, Class target) {
- try {
- // ExtensionSource
- /**
- * we can't make a test here, because, the source must be a Property (ExtensionEnd) and it's a Stereotype
- *
- * @see org.eclipse.papyrus.uml.diagram.profile.custom.policies.CUMLBaseItemSemanticEditPolicy for the good test!
- */
- // ExtensionTarget
- /**
- * we can't make a test here, because, the source must be a Property (ExtensionEnd) and it's a Stereotype
- *
- * @see org.eclipse.papyrus.uml.diagram.profile.custom.policies.CUMLBaseItemSemanticEditPolicy for the good test!
- */
- return true;
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * @generated
- */
- public boolean canExistAssociation_4001(Package container, Association linkInstance, Type source, Type target) {
- try {
- // AssociationSource
- if ((source instanceof Type) && Util.isMetaclass(source)) {
- return false;
- }
- if (source instanceof Extension) {
- return false;
- }
- // AssociationTarget
- if (target != null) {
- if (target instanceof Extension) {
- return false;
- }
- }
- return true;
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * @generated
- */
- public boolean canExistProfileApplication_1045(Package container, ProfileApplication linkInstance, Package source, Profile target) {
- return true;
- }
-
- /**
- * @generated
- */
- public boolean canExistAssociation_4019(Package container, Association linkInstance, Type source, Type target) {
- try {
- // AssociationSource
- if ((source instanceof Type) && Util.isMetaclass(source)) {
- return false;
- }
- if (source instanceof Extension) {
- return false;
- }
- // AssociationTarget
- if (target != null) {
- if (target instanceof Extension) {
- return false;
- }
- }
- return true;
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * @generated
- */
- public boolean canExistGeneralization_4002(Generalization linkInstance, Classifier source, Classifier target) {
- try {
- // GeneralizationSource
- if (!(source instanceof Classifier)) {
- return false;
- }
- if (Util.isMetaclass(source)) {
- return false;
- }
- if (source instanceof Extension) {
- return false; // meaningless
- }
- // GeneralizationTarget
- if (target != null) {
- if (!(target instanceof Classifier)) {
- return false;
- }
- if (Util.isMetaclass(target)) {
- return false;
- }
- if (target instanceof Extension) {
- return false;// meaningless
- }
- }
- return true;
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * @generated
- */
- public boolean canExistDependency_4008(Package container, Dependency linkInstance, NamedElement source, NamedElement target) {
- try {
- // DependencySource
- if ((source instanceof Type) && Util.isMetaclass((Type) source)) {
- return false;
- }
- if (source instanceof Extension) {
- return false;
- }
- // DependencyTarget
- if (target != null) {
- if (target instanceof Extension) {
- return false;
- }
- }
- return true;
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * @generated
- */
- public boolean canExistDependency_4018(Package container, Dependency linkInstance, NamedElement source, NamedElement target) {
- try {
- // DependencySource
- if ((source instanceof Type) && Util.isMetaclass((Type) source)) {
- return false;
- }
- if (source instanceof Extension) {
- return false;
- }
- // DependencyTarget
- if (target != null) {
- if (target instanceof Extension) {
- return false;
- }
- }
- return true;
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * @generated
- */
- public boolean canExistElementImport_1064(Namespace container, ElementImport linkInstance, Namespace source, PackageableElement target) {
- try {
- // ElementImportSource
- if ((source instanceof Type) && Util.isMetaclass((Type) source)) {
- return false;
- }
- if (source instanceof Extension) {
- return false;
- }
- // ElementImportTarget
- if (target != null) {
- if (target instanceof Extension) {
- return false;
- }
- }
- return true;
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * @generated
- */
- public boolean canExistPackageImport_1065(Namespace container, PackageImport linkInstance, Namespace source, Package target) {
- try {
- // PackageImportSource
- if ((source instanceof Type) && Util.isMetaclass((Type) source)) {
- return false;
- }
- if (source instanceof Extension) {
- return false;
- }
- return true;
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * @generated
- */
- public boolean canExistCommentAnnotatedElement_1022(Comment source, Element target) {
- try {
- // AnnotatedElementLink target
- if ((target instanceof Type) && Util.isMetaclass((Type) target)) {
- return false;
- }
- return true;
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * @generated
- */
- public boolean canExistConstraintConstrainedElement_4014(Constraint source, Element target) {
- try {
- // ConstraintedElementLink
- if ((target instanceof Type) && Util.isMetaclass((Type) target)) {
- return false;
- }
- return true;
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
- return false;
- }
- }
-
- /**
- * @generated
- */
- public boolean canExistConstraintContext_8500(Constraint source, Namespace target) {
- return true;
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand;
+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;
+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.DestroyRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+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.emf.type.core.requests.SetRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.edit.helpers.GeneratedEditHelperBase;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.profile.utils.Util;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.ElementImport;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageImport;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.ProfileApplication;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Type;
+
+/**
+ * @generated
+ */
+public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy {
+
+ /**
+ * Extended request data key to hold editpart visual id.
+ *
+ * @generated
+ */
+ public static final String VISUAL_ID_KEY = "visual_id"; //$NON-NLS-1$
+
+ /**
+ * Extended request data key to hold the edge view during a reconnect request.
+ *
+ * @generated
+ */
+ public static final String GRAPHICAL_RECONNECTED_EDGE = "graphical_edge"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ private final IElementType myElementType;
+
+ /**
+ * @generated
+ */
+ protected UMLBaseItemSemanticEditPolicy(IElementType elementType) {
+ myElementType = elementType;
+ }
+
+ /**
+ * Extended request data key to hold editpart visual id.
+ * Add visual id of edited editpart to extended data of the request
+ * so command switch can decide what kind of diagram element is being edited.
+ * It is done in those cases when it's not possible to deduce diagram
+ * element kind from domain element.
+ * Add the reoriented view to the request extended data so that the view
+ * currently edited can be distinguished from other views of the same element
+ * and these latter possibly removed if they become inconsistent after reconnect
+ *
+ * @generated
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Command getCommand(Request request) {
+ if (request instanceof ReconnectRequest) {
+ Object view = ((ReconnectRequest) request).getConnectionEditPart().getModel();
+ if (view instanceof View) {
+ Integer id = new Integer(UMLVisualIDRegistry.getVisualID((View) view));
+ request.getExtendedData().put(VISUAL_ID_KEY, id);
+ request.getExtendedData().put(GRAPHICAL_RECONNECTED_EDGE, (View) view);
+ }
+ }
+ return super.getCommand(request);
+ }
+
+ /**
+ * Returns visual id from request parameters.
+ *
+ * @generated
+ */
+ protected int getVisualID(IEditCommandRequest request) {
+ Object id = request.getParameter(VISUAL_ID_KEY);
+ return id instanceof Integer ? ((Integer) id).intValue() : -1;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getSemanticCommand(IEditCommandRequest request) {
+ IEditCommandRequest completedRequest = completeRequest(request);
+ Command semanticCommand = getSemanticCommandSwitch(completedRequest);
+ semanticCommand = getEditHelperCommand(completedRequest, semanticCommand);
+ if (completedRequest instanceof DestroyRequest) {
+ DestroyRequest destroyRequest = (DestroyRequest) completedRequest;
+ return shouldProceed(destroyRequest) ? addDeleteViewCommand(semanticCommand, destroyRequest) : null;
+ }
+ return semanticCommand;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command addDeleteViewCommand(Command mainCommand, DestroyRequest completedRequest) {
+ Command deleteViewCommand = getGEFWrapper(new DeleteCommand(getEditingDomain(), (View) getHost().getModel()));
+ return mainCommand == null ? deleteViewCommand : mainCommand.chain(deleteViewCommand);
+ }
+
+ /**
+ * @generated
+ */
+ private Command getEditHelperCommand(IEditCommandRequest request, Command editPolicyCommand) {
+ if (editPolicyCommand != null) {
+ ICommand command = editPolicyCommand instanceof ICommandProxy ? ((ICommandProxy) editPolicyCommand).getICommand() : new CommandProxy(editPolicyCommand);
+ request.setParameter(GeneratedEditHelperBase.EDIT_POLICY_COMMAND, command);
+ }
+ IElementType requestContextElementType = getContextElementType(request);
+ request.setParameter(GeneratedEditHelperBase.CONTEXT_ELEMENT_TYPE, requestContextElementType);
+ ICommand command = requestContextElementType.getEditCommand(request);
+ request.setParameter(GeneratedEditHelperBase.EDIT_POLICY_COMMAND, null);
+ request.setParameter(GeneratedEditHelperBase.CONTEXT_ELEMENT_TYPE, null);
+ if (command != null) {
+ if (!(command instanceof CompositeTransactionalCommand)) {
+ command = new CompositeTransactionalCommand(getEditingDomain(), command.getLabel()).compose(command);
+ }
+ return new ICommandProxy(command);
+ }
+ return editPolicyCommand;
+ }
+
+ /**
+ * @generated
+ */
+ protected IElementType getContextElementType(IEditCommandRequest request) {
+ IElementType requestContextElementType = UMLElementTypes.getElementType(getVisualID(request));
+ return requestContextElementType != null ? requestContextElementType : myElementType;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getSemanticCommandSwitch(IEditCommandRequest req) {
+ if (req instanceof CreateRelationshipRequest) {
+ return getCreateRelationshipCommand((CreateRelationshipRequest) req);
+ } else if (req instanceof CreateElementRequest) {
+ return getCreateCommand((CreateElementRequest) req);
+ } else if (req instanceof ConfigureRequest) {
+ return getConfigureCommand((ConfigureRequest) req);
+ } else if (req instanceof DestroyElementRequest) {
+ return getDestroyElementCommand((DestroyElementRequest) req);
+ } else if (req instanceof DestroyReferenceRequest) {
+ return getDestroyReferenceCommand((DestroyReferenceRequest) req);
+ } else if (req instanceof DuplicateElementsRequest) {
+ return getDuplicateCommand((DuplicateElementsRequest) req);
+ } else if (req instanceof GetEditContextRequest) {
+ return getEditContextCommand((GetEditContextRequest) req);
+ } else if (req instanceof MoveRequest) {
+ return getMoveCommand((MoveRequest) req);
+ } else if (req instanceof ReorientReferenceRelationshipRequest) {
+ return getReorientReferenceRelationshipCommand((ReorientReferenceRelationshipRequest) req);
+ } else if (req instanceof ReorientRelationshipRequest) {
+ return getReorientRelationshipCommand((ReorientRelationshipRequest) req);
+ } else if (req instanceof SetRequest) {
+ return getSetCommand((SetRequest) req);
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getConfigureCommand(ConfigureRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateCommand(CreateElementRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ // try to get a semantic create command from the extended type
+ IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(req.getContainer());
+ if (commandProvider != null) {
+ ICommand command = commandProvider.getEditCommand(req);
+ if (command != null && command.canExecute()) {
+ return new ICommandProxy(command);
+ }
+ }
+ }
+ return null;
+ }
+
+ // RS: add code for extended types
+ /**
+ * @generated
+ */
+ protected Command getExtendedTypeCreationCommand(CreateElementRequest request, IExtendedHintedElementType requestElementType) {
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(request.getContainer());
+ if (provider == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ // Retrieve create command from the Element Edit service
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ return getGEFWrapper(createGMFCommand);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getExtendedStartCreateRelationshipCommand(CreateElementRequest request, IExtendedHintedElementType requestElementType) {
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(requestElementType);
+ if (provider == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ // Retrieve create command from the Element Edit service
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ return getGEFWrapper(createGMFCommand);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getExtendedCompleteCreateRelationshipCommand(CreateElementRequest request, IExtendedHintedElementType requestElementType) {
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(requestElementType);
+ if (provider == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ // Retrieve create command from the Element Edit service
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ return getGEFWrapper(createGMFCommand);
+ }
+
+ // RS: End of add code for extended types
+ /**
+ * @generated
+ */
+ protected Command getSetCommand(SetRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getEditContextCommand(GetEditContextRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDuplicateCommand(DuplicateElementsRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getMoveCommand(MoveRequest req) {
+ EObject targetCEObject = req.getTargetContainer();
+ if (targetCEObject != null) {
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(targetCEObject);
+ if (provider != null) {
+ ICommand moveCommand = provider.getEditCommand(req);
+ if (moveCommand != null) {
+ return new ICommandProxy(moveCommand);
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ } else {
+ return getGEFWrapper(new MoveElementsCommand(req));
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ * @generated
+ */
+ protected final Command getGEFWrapper(ICommand cmd) {
+ return new ICommandProxy(cmd);
+ }
+
+ /**
+ * Returns editing domain from the host edit part.
+ *
+ * @generated
+ */
+ protected TransactionalEditingDomain getEditingDomain() {
+ return ((IGraphicalEditPart) getHost()).getEditingDomain();
+ }
+
+ /**
+ * Clean all shortcuts to the host element from the same diagram
+ *
+ * @generated
+ */
+ protected void addDestroyShortcutsCommand(ICompositeCommand cmd, View view) {
+ assert view.getEAnnotation("Shortcut") == null; //$NON-NLS-1$
+ for (Iterator<?> it = view.getDiagram().getChildren().iterator(); it.hasNext();) {
+ View nextView = (View) it.next();
+ if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { //$NON-NLS-1$
+ continue;
+ }
+ cmd.add(new DeleteCommand(getEditingDomain(), nextView));
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public static LinkConstraints getLinkConstraints() {
+ LinkConstraints cached = UMLDiagramEditorPlugin.getInstance().getLinkConstraints();
+ if (cached == null) {
+ UMLDiagramEditorPlugin.getInstance().setLinkConstraints(cached = new LinkConstraints());
+ }
+ return cached;
+ }
+
+ /**
+ * @generated
+ */
+ public static class LinkConstraints {
+
+ /**
+ * @generated
+ */
+ public LinkConstraints() { // use static method #getLinkConstraints() to access instance
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateExtension_1013(Package container, Property source, Class target) {
+ return canExistExtension_1013(
+ container, null, source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateAssociation_4001(Package container, Type source, Type target) {
+ return canExistAssociation_4001(
+ container, null, source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateProfileApplication_1045(Package container, Package source, Profile target) {
+ return canExistProfileApplication_1045(
+ container, null, source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateAssociation_4019(Package container, Type source, Type target) {
+ return canExistAssociation_4019(
+ container, null, source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateGeneralization_4002(Classifier source, Classifier target) {
+ return canExistGeneralization_4002(
+ null, source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateDependency_4008(Package container, NamedElement source, NamedElement target) {
+ return canExistDependency_4008(
+ container, null, source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateDependency_4018(Package container, NamedElement source, NamedElement target) {
+ return canExistDependency_4018(
+ container, null, source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateElementImport_1064(Namespace container, Namespace source, PackageableElement target) {
+ return canExistElementImport_1064(
+ container, null, source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreatePackageImport_1065(Namespace container, Namespace source, Package target) {
+ return canExistPackageImport_1065(
+ container, null, source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateCommentAnnotatedElement_1022(Comment source, Element target) {
+ if (source != null) {
+ if (source.getAnnotatedElements()
+ .contains(target)) {
+ return false;
+ }
+ }
+ return canExistCommentAnnotatedElement_1022(
+ source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateConstraintConstrainedElement_4014(Constraint source, Element target) {
+ if (source != null) {
+ if (source.getConstrainedElements()
+ .contains(target)) {
+ return false;
+ }
+ }
+ return canExistConstraintConstrainedElement_4014(
+ source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canCreateConstraintContext_8500(Constraint source, Namespace target) {
+ if (source != null) {
+ if (source.getContext()
+ != null) {
+ return false;
+ }
+ }
+ if (target != null && (target.getOwnedRules()
+ .contains(target)
+ )) {
+ return false;
+ }
+ return canExistConstraintContext_8500(
+ source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistExtension_1013(Package container, Extension linkInstance, Property source, Class target) {
+ try {
+ //ExtensionSource
+ /**we can't make a test here, because, the source must be a Property (ExtensionEnd) and it's a Stereotype
+ *
+ * @see org.eclipse.papyrus.uml.diagram.profile.custom.policies.CUMLBaseItemSemanticEditPolicy for the good test!
+ */
+ //ExtensionTarget
+ /**we can't make a test here, because, the source must be a Property (ExtensionEnd) and it's a Stereotype
+ *
+ * @see org.eclipse.papyrus.uml.diagram.profile.custom.policies.CUMLBaseItemSemanticEditPolicy for the good test!
+ */
+ return true;
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistAssociation_4001(Package container, Association linkInstance, Type source, Type target) {
+ try {
+ //AssociationSource
+ if ((source instanceof Type) && Util.isMetaclass((Type) source)) {
+ return false;
+ }
+ if (source instanceof Extension) {
+ return false;
+ }
+ //AssociationTarget
+ if (target != null) {
+ if (target instanceof Extension) {
+ return false;
+ }
+ }
+ return true;
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistProfileApplication_1045(Package container, ProfileApplication linkInstance, Package source, Profile target) {
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistAssociation_4019(Package container, Association linkInstance, Type source, Type target) {
+ try {
+ //AssociationSource
+ if ((source instanceof Type) && Util.isMetaclass((Type) source)) {
+ return false;
+ }
+ if (source instanceof Extension) {
+ return false;
+ }
+ //AssociationTarget
+ if (target != null) {
+ if (target instanceof Extension) {
+ return false;
+ }
+ }
+ return true;
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistGeneralization_4002(Generalization linkInstance, Classifier source, Classifier target) {
+ try {
+ //GeneralizationSource
+ if (!(source instanceof Classifier)) {
+ return false;
+ }
+ if (Util.isMetaclass(source)) {
+ return false;
+ }
+ if (source instanceof Extension) {
+ return false; //meaningless
+ }
+ //GeneralizationTarget
+ if (target != null) {
+ if (!(target instanceof Classifier)) {
+ return false;
+ }
+ if (Util.isMetaclass(target)) {
+ return false;
+ }
+ if (target instanceof Extension) {
+ return false;//meaningless
+ }
+ }
+ return true;
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistDependency_4008(Package container, Dependency linkInstance, NamedElement source, NamedElement target) {
+ try {
+ //DependencySource
+ if ((source instanceof Type) && Util.isMetaclass((Type) source)) {
+ return false;
+ }
+ if (source instanceof Extension) {
+ return false;
+ }
+ //DependencyTarget
+ if (target != null) {
+ if (target instanceof Extension) {
+ return false;
+ }
+ }
+ return true;
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistDependency_4018(Package container, Dependency linkInstance, NamedElement source, NamedElement target) {
+ try {
+ //DependencySource
+ if ((source instanceof Type) && Util.isMetaclass((Type) source)) {
+ return false;
+ }
+ if (source instanceof Extension) {
+ return false;
+ }
+ //DependencyTarget
+ if (target != null) {
+ if (target instanceof Extension) {
+ return false;
+ }
+ }
+ return true;
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistElementImport_1064(Namespace container, ElementImport linkInstance, Namespace source, PackageableElement target) {
+ try {
+ //ElementImportSource
+ if ((source instanceof Type) && Util.isMetaclass((Type) source)) {
+ return false;
+ }
+ if (source instanceof Extension) {
+ return false;
+ }
+ //ElementImportTarget
+ if (target != null) {
+ if (target instanceof Extension) {
+ return false;
+ }
+ }
+ return true;
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistPackageImport_1065(Namespace container, PackageImport linkInstance, Namespace source, Package target) {
+ try {
+ //PackageImportSource
+ if ((source instanceof Type) && Util.isMetaclass((Type) source)) {
+ return false;
+ }
+ if (source instanceof Extension) {
+ return false;
+ }
+ return true;
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistCommentAnnotatedElement_1022(Comment source, Element target) {
+ try {
+ //AnnotatedElementLink target
+ if ((target instanceof Type) && Util.isMetaclass((Type) target)) {
+ return false;
+ }
+ return true;
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistConstraintConstrainedElement_4014(Constraint source, Element target) {
+ try {
+ //ConstraintedElementLink
+ if ((target instanceof Type) && Util.isMetaclass((Type) target)) {
+ return false;
+ }
+ return true;
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Link constraint evaluation error", e); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExistConstraintContext_8500(Constraint source, Namespace target) {
+ return true;
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLTextNonResizableEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLTextNonResizableEditPolicy.java
index fb8b677db1c..d48b66103da 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLTextNonResizableEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLTextNonResizableEditPolicy.java
@@ -1,242 +1,242 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.FigureListener;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.handles.MoveHandle;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx;
-import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.tooling.runtime.edit.policies.labels.IRefreshableFeedbackEditPolicy;
-
-/**
- * @generated
- */
-public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx implements IRefreshableFeedbackEditPolicy {
-
- /**
- * @generated
- */
- private IFigure selectionFeedbackFigure;
-
- /**
- * @generated
- */
- private IFigure focusFeedbackFigure;
-
- /**
- * @generated
- */
- private FigureListener hostPositionListener;
-
- /**
- * @generated
- */
- @Override
- protected void showPrimarySelection() {
- if (getHostFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getHostFigure()).setSelected(true);
- ((WrappingLabel) getHostFigure()).setFocus(true);
- } else {
- showSelection();
- showFocus();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void showSelection() {
- if (getHostFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getHostFigure()).setSelected(true);
- ((WrappingLabel) getHostFigure()).setFocus(false);
- } else {
- hideSelection();
- addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure());
- getHostFigure().addFigureListener(getHostPositionListener());
- refreshSelectionFeedback();
- hideFocus();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void hideSelection() {
- if (getHostFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getHostFigure()).setSelected(false);
- ((WrappingLabel) getHostFigure()).setFocus(false);
- } else {
- if (selectionFeedbackFigure != null) {
- removeFeedback(selectionFeedbackFigure);
- getHostFigure().removeFigureListener(getHostPositionListener());
- selectionFeedbackFigure = null;
- }
- hideFocus();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void showFocus() {
- if (getHostFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getHostFigure()).setFocus(true);
- } else {
- hideFocus();
- addFeedback(focusFeedbackFigure = createFocusFeedbackFigure());
- refreshFocusFeedback();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void hideFocus() {
- if (getHostFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getHostFigure()).setFocus(false);
- } else {
- if (focusFeedbackFigure != null) {
- removeFeedback(focusFeedbackFigure);
- focusFeedbackFigure = null;
- }
- }
- }
-
- /**
- * @generated
- */
- protected Rectangle getFeedbackBounds() {
- Rectangle bounds;
- if (getHostFigure() instanceof Label) {
- bounds = ((Label) getHostFigure()).getTextBounds();
- bounds.intersect(getHostFigure().getBounds());
- } else {
- bounds = getHostFigure().getBounds().getCopy();
- }
- getHostFigure().getParent().translateToAbsolute(bounds);
- getFeedbackLayer().translateToRelative(bounds);
- return bounds;
- }
-
- /**
- * @generated
- */
- protected IFigure createSelectionFeedbackFigure() {
- if (getHostFigure() instanceof Label) {
- Label feedbackFigure = new Label();
- feedbackFigure.setOpaque(true);
- feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected);
- feedbackFigure.setForegroundColor(ColorConstants.menuForegroundSelected);
- return feedbackFigure;
- } else {
- RectangleFigure feedbackFigure = new RectangleFigure();
- feedbackFigure.setFill(false);
- return feedbackFigure;
- }
- }
-
- /**
- * @generated
- */
- protected IFigure createFocusFeedbackFigure() {
- return new Figure() {
-
- @Override
- protected void paintFigure(Graphics graphics) {
- graphics.drawFocus(getBounds().getResized(-1, -1));
- }
- };
- }
-
- /**
- * @generated
- */
- protected void updateLabel(Label target) {
- Label source = (Label) getHostFigure();
- target.setText(source.getText());
- target.setTextAlignment(source.getTextAlignment());
- target.setFont(source.getFont());
- }
-
- /**
- * @generated
- */
- protected void refreshSelectionFeedback() {
- if (selectionFeedbackFigure != null) {
- if (selectionFeedbackFigure instanceof Label) {
- updateLabel((Label) selectionFeedbackFigure);
- selectionFeedbackFigure.setBounds(getFeedbackBounds());
- } else {
- selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5, 5));
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshFocusFeedback() {
- if (focusFeedbackFigure != null) {
- focusFeedbackFigure.setBounds(getFeedbackBounds());
- }
- }
-
- /**
- * @generated
- */
- public void refreshFeedback() {
- refreshSelectionFeedback();
- refreshFocusFeedback();
- }
-
- /**
- * @generated
- */
- private FigureListener getHostPositionListener() {
- if (hostPositionListener == null) {
- hostPositionListener = new FigureListener() {
-
- public void figureMoved(IFigure source) {
- refreshFeedback();
- }
- };
- }
- return hostPositionListener;
- }
-
- /**
- * @generated
- */
- @Override
- protected List<?> createSelectionHandles() {
- MoveHandle moveHandle = new MoveHandle((GraphicalEditPart) getHost());
- moveHandle.setBorder(null);
- moveHandle.setDragTracker(new DragEditPartsTrackerEx(getHost()));
- return Collections.singletonList(moveHandle);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.FigureListener;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx;
+import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.tooling.runtime.edit.policies.labels.IRefreshableFeedbackEditPolicy;
+
+/**
+ * @generated
+ */
+public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx implements IRefreshableFeedbackEditPolicy {
+
+ /**
+ * @generated
+ */
+ private IFigure selectionFeedbackFigure;
+
+ /**
+ * @generated
+ */
+ private IFigure focusFeedbackFigure;
+
+ /**
+ * @generated
+ */
+ private FigureListener hostPositionListener;
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void showPrimarySelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(true);
+ ((WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ showSelection();
+ showFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void showSelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(true);
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ hideSelection();
+ addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure());
+ getHostFigure().addFigureListener(getHostPositionListener());
+ refreshSelectionFeedback();
+ hideFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void hideSelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(false);
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (selectionFeedbackFigure != null) {
+ removeFeedback(selectionFeedbackFigure);
+ getHostFigure().removeFigureListener(getHostPositionListener());
+ selectionFeedbackFigure = null;
+ }
+ hideFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void showFocus() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ hideFocus();
+ addFeedback(focusFeedbackFigure = createFocusFeedbackFigure());
+ refreshFocusFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void hideFocus() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (focusFeedbackFigure != null) {
+ removeFeedback(focusFeedbackFigure);
+ focusFeedbackFigure = null;
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Rectangle getFeedbackBounds() {
+ Rectangle bounds;
+ if (getHostFigure() instanceof Label) {
+ bounds = ((Label) getHostFigure()).getTextBounds();
+ bounds.intersect(getHostFigure().getBounds());
+ } else {
+ bounds = getHostFigure().getBounds().getCopy();
+ }
+ getHostFigure().getParent().translateToAbsolute(bounds);
+ getFeedbackLayer().translateToRelative(bounds);
+ return bounds;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createSelectionFeedbackFigure() {
+ if (getHostFigure() instanceof Label) {
+ Label feedbackFigure = new Label();
+ feedbackFigure.setOpaque(true);
+ feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected);
+ feedbackFigure.setForegroundColor(ColorConstants.menuForegroundSelected);
+ return feedbackFigure;
+ } else {
+ RectangleFigure feedbackFigure = new RectangleFigure();
+ feedbackFigure.setFill(false);
+ return feedbackFigure;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFocusFeedbackFigure() {
+ return new Figure() {
+
+ protected void paintFigure(Graphics graphics) {
+ graphics.drawFocus(getBounds().getResized(-1, -1));
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ protected void updateLabel(Label target) {
+ Label source = (Label) getHostFigure();
+ target.setText(source.getText());
+ target.setTextAlignment(source.getTextAlignment());
+ target.setFont(source.getFont());
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshSelectionFeedback() {
+ if (selectionFeedbackFigure != null) {
+ if (selectionFeedbackFigure instanceof Label) {
+ updateLabel((Label) selectionFeedbackFigure);
+ selectionFeedbackFigure.setBounds(getFeedbackBounds());
+ } else {
+ selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5, 5));
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFocusFeedback() {
+ if (focusFeedbackFigure != null) {
+ focusFeedbackFigure.setBounds(getFeedbackBounds());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void refreshFeedback() {
+ refreshSelectionFeedback();
+ refreshFocusFeedback();
+ }
+
+ /**
+ * @generated
+ */
+ private FigureListener getHostPositionListener() {
+ if (hostPositionListener == null) {
+ hostPositionListener = new FigureListener() {
+
+ public void figureMoved(IFigure source) {
+ refreshFeedback();
+ }
+ };
+ }
+ return hostPositionListener;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected List<?> createSelectionHandles() {
+ MoveHandle moveHandle =
+ new MoveHandle((GraphicalEditPart) getHost());
+ moveHandle.setBorder(null);
+ moveHandle.setDragTracker(new DragEditPartsTrackerEx(getHost()));
+ return Collections.singletonList(moveHandle);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLTextSelectionEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLTextSelectionEditPolicy.java
index d204010716f..5237f8ab09c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLTextSelectionEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/policies/UMLTextSelectionEditPolicy.java
@@ -1,225 +1,224 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.FigureListener;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.editpolicies.SelectionEditPolicy;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.tooling.runtime.edit.policies.labels.IRefreshableFeedbackEditPolicy;
-
-/**
- * @generated
- */
-public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements IRefreshableFeedbackEditPolicy {
-
- /**
- * @generated
- */
- private IFigure selectionFeedbackFigure;
-
- /**
- * @generated
- */
- private IFigure focusFeedbackFigure;
-
- /**
- * @generated
- */
- private FigureListener hostPositionListener;
-
- /**
- * @generated
- */
- @Override
- protected void showPrimarySelection() {
- if (getHostFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getHostFigure()).setSelected(true);
- ((WrappingLabel) getHostFigure()).setFocus(true);
- } else {
- showSelection();
- showFocus();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void showSelection() {
- if (getHostFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getHostFigure()).setSelected(true);
- ((WrappingLabel) getHostFigure()).setFocus(false);
- } else {
- hideSelection();
- addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure());
- getHostFigure().addFigureListener(getHostPositionListener());
- refreshSelectionFeedback();
- hideFocus();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void hideSelection() {
- if (getHostFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getHostFigure()).setSelected(false);
- ((WrappingLabel) getHostFigure()).setFocus(false);
- } else {
- if (selectionFeedbackFigure != null) {
- removeFeedback(selectionFeedbackFigure);
- getHostFigure().removeFigureListener(getHostPositionListener());
- selectionFeedbackFigure = null;
- }
- hideFocus();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void showFocus() {
- if (getHostFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getHostFigure()).setFocus(true);
- } else {
- hideFocus();
- addFeedback(focusFeedbackFigure = createFocusFeedbackFigure());
- refreshFocusFeedback();
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void hideFocus() {
- if (getHostFigure() instanceof WrappingLabel) {
- ((WrappingLabel) getHostFigure()).setFocus(false);
- } else {
- if (focusFeedbackFigure != null) {
- removeFeedback(focusFeedbackFigure);
- focusFeedbackFigure = null;
- }
- }
- }
-
- /**
- * @generated
- */
- protected Rectangle getFeedbackBounds() {
- Rectangle bounds;
- if (getHostFigure() instanceof Label) {
- bounds = ((Label) getHostFigure()).getTextBounds();
- bounds.intersect(getHostFigure().getBounds());
- } else {
- bounds = getHostFigure().getBounds().getCopy();
- }
- getHostFigure().getParent().translateToAbsolute(bounds);
- getFeedbackLayer().translateToRelative(bounds);
- return bounds;
- }
-
- /**
- * @generated
- */
- protected IFigure createSelectionFeedbackFigure() {
- if (getHostFigure() instanceof Label) {
- Label feedbackFigure = new Label();
- feedbackFigure.setOpaque(true);
- feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected);
- feedbackFigure.setForegroundColor(ColorConstants.menuForegroundSelected);
- return feedbackFigure;
- } else {
- RectangleFigure feedbackFigure = new RectangleFigure();
- feedbackFigure.setFill(false);
- return feedbackFigure;
- }
- }
-
- /**
- * @generated
- */
- protected IFigure createFocusFeedbackFigure() {
- return new Figure() {
-
- @Override
- protected void paintFigure(Graphics graphics) {
- graphics.drawFocus(getBounds().getResized(-1, -1));
- }
- };
- }
-
- /**
- * @generated
- */
- protected void updateLabel(Label target) {
- Label source = (Label) getHostFigure();
- target.setText(source.getText());
- target.setTextAlignment(source.getTextAlignment());
- target.setFont(source.getFont());
- }
-
- /**
- * @generated
- */
- protected void refreshSelectionFeedback() {
- if (selectionFeedbackFigure != null) {
- if (selectionFeedbackFigure instanceof Label) {
- updateLabel((Label) selectionFeedbackFigure);
- selectionFeedbackFigure.setBounds(getFeedbackBounds());
- } else {
- selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5, 5));
- }
- }
- }
-
- /**
- * @generated
- */
- protected void refreshFocusFeedback() {
- if (focusFeedbackFigure != null) {
- focusFeedbackFigure.setBounds(getFeedbackBounds());
- }
- }
-
- /**
- * @generated
- */
- public void refreshFeedback() {
- refreshSelectionFeedback();
- refreshFocusFeedback();
- }
-
- /**
- * @generated
- */
- private FigureListener getHostPositionListener() {
- if (hostPositionListener == null) {
- hostPositionListener = new FigureListener() {
-
- public void figureMoved(IFigure source) {
- refreshFeedback();
- }
- };
- }
- return hostPositionListener;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.edit.policies;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.FigureListener;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.editpolicies.SelectionEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.tooling.runtime.edit.policies.labels.IRefreshableFeedbackEditPolicy;
+
+/**
+ * @generated
+ */
+public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements IRefreshableFeedbackEditPolicy {
+
+ /**
+ * @generated
+ */
+ private IFigure selectionFeedbackFigure;
+
+ /**
+ * @generated
+ */
+ private IFigure focusFeedbackFigure;
+
+ /**
+ * @generated
+ */
+ private FigureListener hostPositionListener;
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void showPrimarySelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(true);
+ ((WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ showSelection();
+ showFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void showSelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(true);
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ hideSelection();
+ addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure());
+ getHostFigure().addFigureListener(getHostPositionListener());
+ refreshSelectionFeedback();
+ hideFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void hideSelection() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setSelected(false);
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (selectionFeedbackFigure != null) {
+ removeFeedback(selectionFeedbackFigure);
+ getHostFigure().removeFigureListener(getHostPositionListener());
+ selectionFeedbackFigure = null;
+ }
+ hideFocus();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void showFocus() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ hideFocus();
+ addFeedback(focusFeedbackFigure = createFocusFeedbackFigure());
+ refreshFocusFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void hideFocus() {
+ if (getHostFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (focusFeedbackFigure != null) {
+ removeFeedback(focusFeedbackFigure);
+ focusFeedbackFigure = null;
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Rectangle getFeedbackBounds() {
+ Rectangle bounds;
+ if (getHostFigure() instanceof Label) {
+ bounds = ((Label) getHostFigure()).getTextBounds();
+ bounds.intersect(getHostFigure().getBounds());
+ } else {
+ bounds = getHostFigure().getBounds().getCopy();
+ }
+ getHostFigure().getParent().translateToAbsolute(bounds);
+ getFeedbackLayer().translateToRelative(bounds);
+ return bounds;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createSelectionFeedbackFigure() {
+ if (getHostFigure() instanceof Label) {
+ Label feedbackFigure = new Label();
+ feedbackFigure.setOpaque(true);
+ feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected);
+ feedbackFigure.setForegroundColor(ColorConstants.menuForegroundSelected);
+ return feedbackFigure;
+ } else {
+ RectangleFigure feedbackFigure = new RectangleFigure();
+ feedbackFigure.setFill(false);
+ return feedbackFigure;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFocusFeedbackFigure() {
+ return new Figure() {
+
+ protected void paintFigure(Graphics graphics) {
+ graphics.drawFocus(getBounds().getResized(-1, -1));
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ protected void updateLabel(Label target) {
+ Label source = (Label) getHostFigure();
+ target.setText(source.getText());
+ target.setTextAlignment(source.getTextAlignment());
+ target.setFont(source.getFont());
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshSelectionFeedback() {
+ if (selectionFeedbackFigure != null) {
+ if (selectionFeedbackFigure instanceof Label) {
+ updateLabel((Label) selectionFeedbackFigure);
+ selectionFeedbackFigure.setBounds(getFeedbackBounds());
+ } else {
+ selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5, 5));
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFocusFeedback() {
+ if (focusFeedbackFigure != null) {
+ focusFeedbackFigure.setBounds(getFeedbackBounds());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void refreshFeedback() {
+ refreshSelectionFeedback();
+ refreshFocusFeedback();
+ }
+
+ /**
+ * @generated
+ */
+ private FigureListener getHostPositionListener() {
+ if (hostPositionListener == null) {
+ hostPositionListener = new FigureListener() {
+
+ public void figureMoved(IFigure source) {
+ refreshFeedback();
+ }
+ };
+ }
+ return hostPositionListener;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/navigator/UMLDomainNavigatorContentProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/navigator/UMLDomainNavigatorContentProvider.java
index 672ff51c95b..77ab4819bd5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/navigator/UMLDomainNavigatorContentProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/navigator/UMLDomainNavigatorContentProvider.java
@@ -1,250 +1,250 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.navigator;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.navigator.ICommonContentExtensionSite;
-import org.eclipse.ui.navigator.ICommonContentProvider;
-
-/**
- * @generated
- */
-public class UMLDomainNavigatorContentProvider implements ICommonContentProvider {
-
- /**
- * @generated
- */
- private AdapterFactoryContentProvider myAdapterFctoryContentProvier;
-
- /**
- * @generated
- */
- private static final Object[] EMPTY_ARRAY = new Object[0];
-
- /**
- * @generated
- */
- private Viewer myViewer;
-
- /**
- * @generated
- */
- private AdapterFactoryEditingDomain myEditingDomain;
-
- /**
- * @generated
- */
- private WorkspaceSynchronizer myWorkspaceSynchronizer;
-
- /**
- * @generated
- */
- private Runnable myViewerRefreshRunnable;
-
- /**
- * @generated
- */
- public UMLDomainNavigatorContentProvider() {
- myAdapterFctoryContentProvier = new AdapterFactoryContentProvider(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory());
- TransactionalEditingDomain editingDomain = WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain();
- myEditingDomain = (AdapterFactoryEditingDomain) editingDomain;
- @SuppressWarnings("serial")
- Map<Resource, Boolean> map = new HashMap<Resource, Boolean>() {
-
- @Override
- public Boolean get(java.lang.Object key) {
- if (!containsKey(key)) {
- if (key instanceof Resource) {
- put((Resource) key, Boolean.TRUE);
- }
- }
- return super.get(key);
- }
- };
- myEditingDomain.setResourceToReadOnlyMap(map);
- myViewerRefreshRunnable = new Runnable() {
-
- public void run() {
- if (myViewer != null) {
- myViewer.refresh();
- }
- }
- };
- myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain, new WorkspaceSynchronizer.Delegate() {
-
- public void dispose() {
- }
-
- public boolean handleResourceChanged(final Resource resource) {
- for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
- Resource nextResource = it.next();
- nextResource.unload();
- }
- if (myViewer != null) {
- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
- }
- return true;
- }
-
- public boolean handleResourceDeleted(Resource resource) {
- for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
- Resource nextResource = it.next();
- nextResource.unload();
- }
- if (myViewer != null) {
- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
- }
- return true;
- }
-
- public boolean handleResourceMoved(Resource resource, final URI newURI) {
- for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
- Resource nextResource = it.next();
- nextResource.unload();
- }
- if (myViewer != null) {
- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
- }
- return true;
- }
- });
- }
-
- /**
- * @generated
- */
- public void dispose() {
- myWorkspaceSynchronizer.dispose();
- myWorkspaceSynchronizer = null;
- myViewerRefreshRunnable = null;
- for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
- Resource resource = it.next();
- resource.unload();
- }
- ((TransactionalEditingDomain) myEditingDomain).dispose();
- myEditingDomain = null;
- }
-
- /**
- * @generated
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- myViewer = viewer;
- }
-
- /**
- * @generated
- */
- void unloadAllResources() {
- for (Resource nextResource : myEditingDomain.getResourceSet().getResources()) {
- nextResource.unload();
- }
- }
-
- /**
- * @generated
- */
- void asyncRefresh() {
- if (myViewer != null && !myViewer.getControl().isDisposed()) {
- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
- }
- }
-
- /**
- * @generated
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- /**
- * @generated
- */
- public void restoreState(IMemento aMemento) {
- }
-
- /**
- * @generated
- */
- public void saveState(IMemento aMemento) {
- }
-
- /**
- * @generated
- */
- public void init(ICommonContentExtensionSite aConfig) {
- }
-
- /**
- * @generated
- */
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof IFile) {
- IFile file = (IFile) parentElement;
- URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
- Resource resource = myEditingDomain.getResourceSet().getResource(fileURI, true);
- return wrapEObjects(myAdapterFctoryContentProvier.getChildren(resource), parentElement);
- }
- if (parentElement instanceof UMLDomainNavigatorItem) {
- return wrapEObjects(myAdapterFctoryContentProvier.getChildren(((UMLDomainNavigatorItem) parentElement).getEObject()), parentElement);
- }
- return EMPTY_ARRAY;
- }
-
- /**
- * @generated
- */
- public Object[] wrapEObjects(Object[] objects, Object parentElement) {
- Collection<UMLDomainNavigatorItem> result = new ArrayList<UMLDomainNavigatorItem>();
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof EObject) {
- result.add(new UMLDomainNavigatorItem((EObject) objects[i], parentElement, myAdapterFctoryContentProvier));
- }
- }
- return result.toArray();
- }
-
- /**
- * @generated
- */
- public Object getParent(Object element) {
- if (element instanceof UMLAbstractNavigatorItem) {
- UMLAbstractNavigatorItem abstractNavigatorItem = (UMLAbstractNavigatorItem) element;
- return abstractNavigatorItem.getParent();
- }
- return null;
- }
-
- /**
- * @generated
- */
- public boolean hasChildren(Object element) {
- return element instanceof IFile || getChildren(element).length > 0;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.navigator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+
+/**
+ * @generated
+ */
+public class UMLDomainNavigatorContentProvider implements ICommonContentProvider {
+
+ /**
+ * @generated
+ */
+ private AdapterFactoryContentProvider myAdapterFctoryContentProvier;
+
+ /**
+ * @generated
+ */
+ private static final Object[] EMPTY_ARRAY = new Object[0];
+
+ /**
+ * @generated
+ */
+ private Viewer myViewer;
+
+ /**
+ * @generated
+ */
+ private AdapterFactoryEditingDomain myEditingDomain;
+
+ /**
+ * @generated
+ */
+ private WorkspaceSynchronizer myWorkspaceSynchronizer;
+
+ /**
+ * @generated
+ */
+ private Runnable myViewerRefreshRunnable;
+
+ /**
+ * @generated
+ */
+ public UMLDomainNavigatorContentProvider() {
+ myAdapterFctoryContentProvier = new AdapterFactoryContentProvider(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory());
+ TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain();
+ myEditingDomain = (AdapterFactoryEditingDomain) editingDomain;
+ @SuppressWarnings("serial")
+ Map<Resource, Boolean> map = new HashMap<Resource, Boolean>() {
+
+ public Boolean get(java.lang.Object key) {
+ if (!containsKey(key)) {
+ if (key instanceof Resource) {
+ put((Resource) key, Boolean.TRUE);
+ }
+ }
+ return super.get(key);
+ }
+ };
+ myEditingDomain.setResourceToReadOnlyMap(map);
+ myViewerRefreshRunnable = new Runnable() {
+
+ public void run() {
+ if (myViewer != null) {
+ myViewer.refresh();
+ }
+ }
+ };
+ myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain, new WorkspaceSynchronizer.Delegate() {
+
+ public void dispose() {
+ }
+
+ public boolean handleResourceChanged(final Resource resource) {
+ for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+
+ public boolean handleResourceDeleted(Resource resource) {
+ for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+
+ public boolean handleResourceMoved(Resource resource, final URI newURI) {
+ for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ myWorkspaceSynchronizer.dispose();
+ myWorkspaceSynchronizer = null;
+ myViewerRefreshRunnable = null;
+ for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ Resource resource = (Resource) it.next();
+ resource.unload();
+ }
+ ((TransactionalEditingDomain) myEditingDomain).dispose();
+ myEditingDomain = null;
+ }
+
+ /**
+ * @generated
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ myViewer = viewer;
+ }
+
+ /**
+ * @generated
+ */
+ void unloadAllResources() {
+ for (Resource nextResource : myEditingDomain.getResourceSet().getResources()) {
+ nextResource.unload();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ void asyncRefresh() {
+ if (myViewer != null && !myViewer.getControl().isDisposed()) {
+ myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /**
+ * @generated
+ */
+ public void restoreState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public void saveState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public void init(ICommonContentExtensionSite aConfig) {
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof IFile) {
+ IFile file = (IFile) parentElement;
+ URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+ Resource resource = myEditingDomain.getResourceSet().getResource(fileURI, true);
+ return wrapEObjects(myAdapterFctoryContentProvier.getChildren(resource), parentElement);
+ }
+ if (parentElement instanceof UMLDomainNavigatorItem) {
+ return wrapEObjects(myAdapterFctoryContentProvier.getChildren(((UMLDomainNavigatorItem) parentElement).getEObject()), parentElement);
+ }
+ return EMPTY_ARRAY;
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] wrapEObjects(Object[] objects, Object parentElement) {
+ Collection<UMLDomainNavigatorItem> result = new ArrayList<UMLDomainNavigatorItem>();
+ for (int i = 0; i < objects.length; i++) {
+ if (objects[i] instanceof EObject) {
+ result.add(new UMLDomainNavigatorItem((EObject) objects[i], parentElement, myAdapterFctoryContentProvier));
+ }
+ }
+ return result.toArray();
+ }
+
+ /**
+ * @generated
+ */
+ public Object getParent(Object element) {
+ if (element instanceof UMLAbstractNavigatorItem) {
+ UMLAbstractNavigatorItem abstractNavigatorItem = (UMLAbstractNavigatorItem) element;
+ return abstractNavigatorItem.getParent();
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean hasChildren(Object element) {
+ return element instanceof IFile || getChildren(element).length > 0;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/navigator/UMLNavigatorContentProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/navigator/UMLNavigatorContentProvider.java
index 95aa769be0f..8b9b6198554 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/navigator/UMLNavigatorContentProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/navigator/UMLNavigatorContentProvider.java
@@ -1,264 +1,264 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.navigator;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.navigator.ICommonContentExtensionSite;
-import org.eclipse.ui.navigator.ICommonContentProvider;
-
-/**
- * @generated
- */
-public class UMLNavigatorContentProvider implements ICommonContentProvider {
-
- /**
- * @generated
- */
- private static final Object[] EMPTY_ARRAY = new Object[0];
-
- /**
- * @generated
- */
- private Viewer myViewer;
-
- /**
- * @generated
- */
- private AdapterFactoryEditingDomain myEditingDomain;
-
- /**
- * @generated
- */
- private WorkspaceSynchronizer myWorkspaceSynchronizer;
-
- /**
- * @generated
- */
- private Runnable myViewerRefreshRunnable;
-
- /**
- * @generated
- */
- public UMLNavigatorContentProvider() {
- TransactionalEditingDomain editingDomain = WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain();
- myEditingDomain = (AdapterFactoryEditingDomain) editingDomain;
- @SuppressWarnings("serial")
- Map<Resource, Boolean> map = new HashMap<Resource, Boolean>() {
-
- @Override
- public Boolean get(java.lang.Object key) {
- if (!containsKey(key)) {
- if (key instanceof Resource) {
- put((Resource) key, Boolean.TRUE);
- }
- }
- return super.get(key);
- }
- };
- myEditingDomain.setResourceToReadOnlyMap(map);
- myViewerRefreshRunnable = new Runnable() {
-
- public void run() {
- if (myViewer != null) {
- myViewer.refresh();
- }
- }
- };
- myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain, new WorkspaceSynchronizer.Delegate() {
-
- public void dispose() {
- }
-
- public boolean handleResourceChanged(final Resource resource) {
- for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
- Resource nextResource = it.next();
- nextResource.unload();
- }
- if (myViewer != null) {
- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
- }
- return true;
- }
-
- public boolean handleResourceDeleted(Resource resource) {
- for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
- Resource nextResource = it.next();
- nextResource.unload();
- }
- if (myViewer != null) {
- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
- }
- return true;
- }
-
- public boolean handleResourceMoved(Resource resource, final URI newURI) {
- for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
- Resource nextResource = it.next();
- nextResource.unload();
- }
- if (myViewer != null) {
- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
- }
- return true;
- }
- });
- }
-
- /**
- * @generated
- */
- public void dispose() {
- myWorkspaceSynchronizer.dispose();
- myWorkspaceSynchronizer = null;
- myViewerRefreshRunnable = null;
- for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
- Resource resource = it.next();
- resource.unload();
- }
- ((TransactionalEditingDomain) myEditingDomain).dispose();
- myEditingDomain = null;
- }
-
- /**
- * @generated
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- myViewer = viewer;
- }
-
- /**
- * @generated
- */
- void unloadAllResources() {
- for (Resource nextResource : myEditingDomain.getResourceSet().getResources()) {
- nextResource.unload();
- }
- }
-
- /**
- * @generated
- */
- void asyncRefresh() {
- if (myViewer != null && !myViewer.getControl().isDisposed()) {
- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
- }
- }
-
- /**
- * @generated
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- /**
- * @generated
- */
- public void restoreState(IMemento aMemento) {
- }
-
- /**
- * @generated
- */
- public void saveState(IMemento aMemento) {
- }
-
- /**
- * @generated
- */
- public void init(ICommonContentExtensionSite aConfig) {
- }
-
- /**
- * @generated
- */
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof IFile) {
- IFile file = (IFile) parentElement;
- URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
- Resource resource = myEditingDomain.getResourceSet().getResource(fileURI, true);
- Collection<Object> result = new ArrayList<Object>();
- List<View> topViews = new ArrayList<View>(resource.getContents().size());
- for (EObject o : resource.getContents()) {
- if (o instanceof View) {
- topViews.add((View) o);
- }
- }
- return result.toArray();
- }
- if (parentElement instanceof UMLNavigatorGroup) {
- UMLNavigatorGroup group = (UMLNavigatorGroup) parentElement;
- return group.getChildren();
- }
- if (parentElement instanceof UMLNavigatorItem) {
- UMLNavigatorItem navigatorItem = (UMLNavigatorItem) parentElement;
- if (navigatorItem.isLeaf() || !isOwnView(navigatorItem.getView())) {
- return EMPTY_ARRAY;
- }
- return getViewChildren(navigatorItem.getView(), parentElement);
- }
- return EMPTY_ARRAY;
- }
-
- /**
- * @generated
- */
- private Object[] getViewChildren(View view, Object parentElement) {
- switch (UMLVisualIDRegistry.getVisualID(view)) {
- }
- return EMPTY_ARRAY;
- }
-
- /**
- * @generated
- */
- private boolean isOwnView(View view) {
- return ProfileDiagramEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(view));
- }
-
- /**
- * @generated
- */
- public Object getParent(Object element) {
- if (element instanceof UMLAbstractNavigatorItem) {
- UMLAbstractNavigatorItem abstractNavigatorItem = (UMLAbstractNavigatorItem) element;
- return abstractNavigatorItem.getParent();
- }
- return null;
- }
-
- /**
- * @generated
- */
- public boolean hasChildren(Object element) {
- return element instanceof IFile || getChildren(element).length > 0;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.navigator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+
+/**
+ * @generated
+ */
+public class UMLNavigatorContentProvider implements ICommonContentProvider {
+
+ /**
+ * @generated
+ */
+ private static final Object[] EMPTY_ARRAY = new Object[0];
+
+ /**
+ * @generated
+ */
+ private Viewer myViewer;
+
+ /**
+ * @generated
+ */
+ private AdapterFactoryEditingDomain myEditingDomain;
+
+ /**
+ * @generated
+ */
+ private WorkspaceSynchronizer myWorkspaceSynchronizer;
+
+ /**
+ * @generated
+ */
+ private Runnable myViewerRefreshRunnable;
+
+ /**
+ * @generated
+ */
+ public UMLNavigatorContentProvider() {
+ TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain();
+ myEditingDomain = (AdapterFactoryEditingDomain) editingDomain;
+ @SuppressWarnings("serial")
+ Map<Resource, Boolean> map = new HashMap<Resource, Boolean>() {
+
+ public Boolean get(java.lang.Object key) {
+ if (!containsKey(key)) {
+ if (key instanceof Resource) {
+ put((Resource) key, Boolean.TRUE);
+ }
+ }
+ return super.get(key);
+ }
+ };
+ myEditingDomain.setResourceToReadOnlyMap(map);
+ myViewerRefreshRunnable = new Runnable() {
+
+ public void run() {
+ if (myViewer != null) {
+ myViewer.refresh();
+ }
+ }
+ };
+ myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain, new WorkspaceSynchronizer.Delegate() {
+
+ public void dispose() {
+ }
+
+ public boolean handleResourceChanged(final Resource resource) {
+ for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+
+ public boolean handleResourceDeleted(Resource resource) {
+ for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+
+ public boolean handleResourceMoved(Resource resource, final URI newURI) {
+ for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ Resource nextResource = (Resource) it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
+ }
+ return true;
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ myWorkspaceSynchronizer.dispose();
+ myWorkspaceSynchronizer = null;
+ myViewerRefreshRunnable = null;
+ for (Iterator<Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ Resource resource = (Resource) it.next();
+ resource.unload();
+ }
+ ((TransactionalEditingDomain) myEditingDomain).dispose();
+ myEditingDomain = null;
+ }
+
+ /**
+ * @generated
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ myViewer = viewer;
+ }
+
+ /**
+ * @generated
+ */
+ void unloadAllResources() {
+ for (Resource nextResource : myEditingDomain.getResourceSet().getResources()) {
+ nextResource.unload();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ void asyncRefresh() {
+ if (myViewer != null && !myViewer.getControl().isDisposed()) {
+ myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /**
+ * @generated
+ */
+ public void restoreState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public void saveState(IMemento aMemento) {
+ }
+
+ /**
+ * @generated
+ */
+ public void init(ICommonContentExtensionSite aConfig) {
+ }
+
+ /**
+ * @generated
+ */
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof IFile) {
+ IFile file = (IFile) parentElement;
+ URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+ Resource resource = myEditingDomain.getResourceSet().getResource(fileURI, true);
+ Collection<Object> result = new ArrayList<Object>();
+ List<View> topViews = new ArrayList<View>(resource.getContents().size());
+ for (EObject o : resource.getContents()) {
+ if (o instanceof View) {
+ topViews.add((View) o);
+ }
+ }
+ return result.toArray();
+ }
+ if (parentElement instanceof UMLNavigatorGroup) {
+ UMLNavigatorGroup group = (UMLNavigatorGroup) parentElement;
+ return group.getChildren();
+ }
+ if (parentElement instanceof UMLNavigatorItem) {
+ UMLNavigatorItem navigatorItem = (UMLNavigatorItem) parentElement;
+ if (navigatorItem.isLeaf() || !isOwnView(navigatorItem.getView())) {
+ return EMPTY_ARRAY;
+ }
+ return getViewChildren(navigatorItem.getView(), parentElement);
+ }
+ return EMPTY_ARRAY;
+ }
+
+ /**
+ * @generated
+ */
+ private Object[] getViewChildren(View view, Object parentElement) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ }
+ return EMPTY_ARRAY;
+ }
+
+ /**
+ * @generated
+ */
+ private boolean isOwnView(View view) {
+ return ProfileDiagramEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(view));
+ }
+
+ /**
+ * @generated
+ */
+ public Object getParent(Object element) {
+ if (element instanceof UMLAbstractNavigatorItem) {
+ UMLAbstractNavigatorItem abstractNavigatorItem = (UMLAbstractNavigatorItem) element;
+ return abstractNavigatorItem.getParent();
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean hasChildren(Object element) {
+ return element instanceof IFile || getChildren(element).length > 0;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/parsers/MessageFormatParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/parsers/MessageFormatParser.java
index 23fa04ca56a..4f7733eab09 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/parsers/MessageFormatParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/parsers/MessageFormatParser.java
@@ -1,203 +1,208 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.parsers;
-
-import java.text.FieldPosition;
-import java.text.MessageFormat;
-import java.text.ParsePosition;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
-import org.eclipse.gmf.tooling.runtime.parsers.AbstractAttributeParser;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
-
-/**
- * @generated
- */
-public class MessageFormatParser extends AbstractAttributeParser {
-
- /**
- * @generated
- */
- private String defaultPattern;
-
- /**
- * @generated
- */
- private String defaultEditablePattern;
-
- /**
- * @generated
- */
- private MessageFormat viewProcessor;
-
- /**
- * @generated
- */
- private MessageFormat editorProcessor;
-
- /**
- * @generated
- */
- private MessageFormat editProcessor;
-
- /**
- * @generated
- */
- public MessageFormatParser(EAttribute[] features) {
- super(features);
- }
-
- /**
- * @generated
- */
- public MessageFormatParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- /**
- * @generated
- */
- protected String getDefaultPattern() {
- if (defaultPattern == null) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < features.length; i++) {
- if (i > 0) {
- sb.append(' ');
- }
- sb.append('{');
- sb.append(i);
- sb.append('}');
- }
- defaultPattern = sb.toString();
- }
- return defaultPattern;
- }
-
- /**
- * @generated
- */
- @Override
- public void setViewPattern(String viewPattern) {
- super.setViewPattern(viewPattern);
- viewProcessor = null;
- }
-
- /**
- * @generated
- */
- @Override
- public void setEditorPattern(String editorPattern) {
- super.setEditorPattern(editorPattern);
- editorProcessor = null;
- }
-
- /**
- * @generated
- */
- protected MessageFormat getViewProcessor() {
- if (viewProcessor == null) {
- viewProcessor = new MessageFormat(getViewPattern() == null ? getDefaultPattern() : getViewPattern());
- }
- return viewProcessor;
- }
-
- /**
- * @generated
- */
- protected MessageFormat getEditorProcessor() {
- if (editorProcessor == null) {
- editorProcessor = new MessageFormat(getEditorPattern() == null ? getDefaultEditablePattern() : getEditorPattern());
- }
- return editorProcessor;
- }
-
- /**
- * @generated
- */
- protected String getDefaultEditablePattern() {
- if (defaultEditablePattern == null) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < editableFeatures.length; i++) {
- if (i > 0) {
- sb.append(' ');
- }
- sb.append('{');
- sb.append(i);
- sb.append('}');
- }
- defaultEditablePattern = sb.toString();
- }
- return defaultEditablePattern;
- }
-
- /**
- * @generated
- */
- @Override
- public void setEditPattern(String editPattern) {
- super.setEditPattern(editPattern);
- editProcessor = null;
- }
-
- /**
- * @generated
- */
- protected MessageFormat getEditProcessor() {
- if (editProcessor == null) {
- editProcessor = new MessageFormat(getEditPattern() == null ? getDefaultEditablePattern() : getEditPattern());
- }
- return editProcessor;
- }
-
- /**
- * @generated
- */
- public String getEditString(IAdaptable adapter, int flags) {
- EObject element = (EObject) adapter.getAdapter(EObject.class);
- return getEditorProcessor().format(getEditableValues(element), new StringBuffer(), new FieldPosition(0)).toString();
- }
-
- /**
- * @generated
- */
- public IParserEditStatus isValidEditString(IAdaptable adapter, String editString) {
- ParsePosition pos = new ParsePosition(0);
- Object[] values = getEditProcessor().parse(editString, pos);
- if (values == null) {
- return new ParserEditStatus(UMLDiagramEditorPlugin.ID, IParserEditStatus.UNEDITABLE, NLS.bind(Messages.MessageFormatParser_InvalidInputError, new Integer(pos.getErrorIndex())));
- }
- return validateNewValues(values);
- }
-
- /**
- * @generated
- */
- public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
- Object[] values = getEditProcessor().parse(newString, new ParsePosition(0));
- return getParseCommand(adapter, values, flags);
- }
-
- /**
- * @generated
- */
- public String getPrintString(IAdaptable adapter, int flags) {
- EObject element = (EObject) adapter.getAdapter(EObject.class);
- return getViewProcessor().format(getValues(element), new StringBuffer(), new FieldPosition(0)).toString();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.parsers;
+
+import java.text.FieldPosition;
+import java.text.MessageFormat;
+import java.text.ParsePosition;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
+import org.eclipse.gmf.tooling.runtime.parsers.AbstractAttributeParser;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.uml.diagram.profile.part.Messages;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
+
+/**
+ * @generated
+ */
+public class MessageFormatParser extends AbstractAttributeParser {
+
+ /**
+ * @generated
+ */
+ private String defaultPattern;
+
+ /**
+ * @generated
+ */
+ private String defaultEditablePattern;
+
+ /**
+ * @generated
+ */
+ private MessageFormat viewProcessor;
+
+ /**
+ * @generated
+ */
+ private MessageFormat editorProcessor;
+
+ /**
+ * @generated
+ */
+ private MessageFormat editProcessor;
+
+ /**
+ * @generated
+ */
+ public MessageFormatParser(EAttribute[] features) {
+ super(features);
+ }
+
+ /**
+ * @generated
+ */
+ public MessageFormatParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ /**
+ * @generated
+ */
+ protected String getDefaultPattern() {
+ if (defaultPattern == null) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < features.length; i++) {
+ if (i > 0) {
+ sb.append(' ');
+ }
+ sb.append('{');
+ sb.append(i);
+ sb.append('}');
+ }
+ defaultPattern = sb.toString();
+ }
+ return defaultPattern;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void setViewPattern(String viewPattern) {
+ super.setViewPattern(viewPattern);
+ viewProcessor = null;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void setEditorPattern(String editorPattern) {
+ super.setEditorPattern(editorPattern);
+ editorProcessor = null;
+ }
+
+ /**
+ * @generated
+ */
+ protected MessageFormat getViewProcessor() {
+ if (viewProcessor == null) {
+ viewProcessor = new MessageFormat(getViewPattern() == null ? getDefaultPattern() : getViewPattern());
+ }
+ return viewProcessor;
+ }
+
+ /**
+ * @generated
+ */
+ protected MessageFormat getEditorProcessor() {
+ if (editorProcessor == null) {
+ editorProcessor = new MessageFormat(getEditorPattern() == null ? getDefaultEditablePattern() : getEditorPattern());
+ }
+ return editorProcessor;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getDefaultEditablePattern() {
+ if (defaultEditablePattern == null) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < editableFeatures.length; i++) {
+ if (i > 0) {
+ sb.append(' ');
+ }
+ sb.append('{');
+ sb.append(i);
+ sb.append('}');
+ }
+ defaultEditablePattern = sb.toString();
+ }
+ return defaultEditablePattern;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void setEditPattern(String editPattern) {
+ super.setEditPattern(editPattern);
+ editProcessor = null;
+ }
+
+ /**
+ * @generated
+ */
+ protected MessageFormat getEditProcessor() {
+ if (editProcessor == null) {
+ editProcessor = new MessageFormat(getEditPattern() == null ? getDefaultEditablePattern() : getEditPattern());
+ }
+ return editProcessor;
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditString(IAdaptable adapter, int flags) {
+ EObject element = (EObject) adapter.getAdapter(EObject.class);
+ return getEditorProcessor().format(getEditableValues(element), new StringBuffer(), new FieldPosition(0)).toString();
+ }
+
+ /**
+ * @generated
+ */
+ public IParserEditStatus isValidEditString(IAdaptable adapter, String editString) {
+ ParsePosition pos = new ParsePosition(0);
+ Object[] values = getEditProcessor().parse(editString, pos);
+ if (values == null) {
+ return new ParserEditStatus(
+ UMLDiagramEditorPlugin.ID,
+ IParserEditStatus.UNEDITABLE,
+ NLS.bind(
+ Messages.MessageFormatParser_InvalidInputError,
+ new Integer(pos.getErrorIndex())));
+ }
+ return validateNewValues(values);
+ }
+
+ /**
+ * @generated
+ */
+ public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
+ Object[] values = getEditProcessor().parse(newString, new ParsePosition(0));
+ return getParseCommand(adapter, values, flags);
+ }
+
+ /**
+ * @generated
+ */
+ public String getPrintString(IAdaptable adapter, int flags) {
+ EObject element = (EObject) adapter.getAdapter(EObject.class);
+ return getViewProcessor().format(getValues(element), new StringBuffer(), new FieldPosition(0)).toString();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/DiagramEditorContextMenuProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/DiagramEditorContextMenuProvider.java
index bc7380ef33c..97ac97fef54 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/DiagramEditorContextMenuProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/DiagramEditorContextMenuProvider.java
@@ -1,59 +1,61 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService;
-import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
-import org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * @generated
- */
-public class DiagramEditorContextMenuProvider extends DiagramContextMenuProvider {
-
- /**
- * @generated
- */
- private IWorkbenchPart part;
-
- /**
- * @generated
- */
- public DiagramEditorContextMenuProvider(IWorkbenchPart part, EditPartViewer viewer) {
- super(part, viewer);
- this.part = part;
- }
-
- /**
- * @generated
- */
- @Override
- public void buildContextMenu(final IMenuManager menu) {
- getViewer().flush();
- try {
- TransactionUtil.getEditingDomain((EObject) getViewer().getContents().getModel()).runExclusive(new Runnable() {
-
- public void run() {
- ContributionItemService.getInstance().contributeToPopupMenu(DiagramEditorContextMenuProvider.this, part);
- menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL);
- }
- });
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Error building context menu", e);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService;
+import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
+import org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @generated
+ */
+public class DiagramEditorContextMenuProvider extends DiagramContextMenuProvider {
+
+ /**
+ * @generated
+ */
+ private IWorkbenchPart part;
+
+ /**
+ * @generated
+ */
+ public DiagramEditorContextMenuProvider(IWorkbenchPart part, EditPartViewer viewer) {
+ super(part, viewer);
+ this.part = part;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void buildContextMenu(final IMenuManager menu) {
+ getViewer().flush();
+ try {
+ TransactionUtil.getEditingDomain(
+ (EObject) getViewer().getContents().getModel()).runExclusive(new Runnable() {
+
+ public void run() {
+ ContributionItemService.getInstance().contributeToPopupMenu(
+ DiagramEditorContextMenuProvider.this, part);
+ menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL);
+ }
+ });
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Error building context menu", e);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLCreationWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLCreationWizard.java
index ea86710f9d5..f0b6cc10300 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLCreationWizard.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLCreationWizard.java
@@ -1,168 +1,174 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-/**
- * @generated
- */
-public class UMLCreationWizard extends Wizard implements INewWizard {
-
- /**
- * @generated
- */
- private IWorkbench workbench;
-
- /**
- * @generated
- */
- protected IStructuredSelection selection;
-
- /**
- * @generated
- */
- protected UMLCreationWizardPage diagramModelFilePage;
-
- /**
- * @generated
- */
- protected UMLCreationWizardPage domainModelFilePage;
-
- /**
- * @generated
- */
- protected Resource diagram;
-
- /**
- * @generated
- */
- private boolean openNewlyCreatedDiagramEditor = true;
-
- /**
- * @generated
- */
- public IWorkbench getWorkbench() {
- return workbench;
- }
-
- /**
- * @generated
- */
- public IStructuredSelection getSelection() {
- return selection;
- }
-
- /**
- * @generated
- */
- public final Resource getDiagram() {
- return diagram;
- }
-
- /**
- * @generated
- */
- public final boolean isOpenNewlyCreatedDiagramEditor() {
- return openNewlyCreatedDiagramEditor;
- }
-
- /**
- * @generated
- */
- public void setOpenNewlyCreatedDiagramEditor(boolean openNewlyCreatedDiagramEditor) {
- this.openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor;
- }
-
- /**
- * @generated
- */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- this.workbench = workbench;
- this.selection = selection;
- setWindowTitle(Messages.UMLCreationWizardTitle);
- setDefaultPageImageDescriptor(UMLDiagramEditorPlugin.getBundledImageDescriptor("icons/wizban/NewUMLWizard.gif")); //$NON-NLS-1$
- setNeedsProgressMonitor(true);
- }
-
- /**
- * @generated
- */
- @Override
- public void addPages() {
- diagramModelFilePage = new UMLCreationWizardPage("DiagramModelFile", getSelection(), "PapyrusUMLProfile_diagram"); //$NON-NLS-1$ //$NON-NLS-2$
- diagramModelFilePage.setTitle(Messages.UMLCreationWizard_DiagramModelFilePageTitle);
- diagramModelFilePage.setDescription(Messages.UMLCreationWizard_DiagramModelFilePageDescription);
- addPage(diagramModelFilePage);
- domainModelFilePage = new UMLCreationWizardPage("DomainModelFile", getSelection(), "PapyrusUMLProfile") { //$NON-NLS-1$ //$NON-NLS-2$
-
- @Override
- public void setVisible(boolean visible) {
- if (visible) {
- String fileName = diagramModelFilePage.getFileName();
- fileName = fileName.substring(0, fileName.length() - ".PapyrusUMLProfile_diagram".length()); //$NON-NLS-1$
- setFileName(UMLDiagramEditorUtil.getUniqueFileName(getContainerFullPath(), fileName, "PapyrusUMLProfile")); //$NON-NLS-1$
- }
- super.setVisible(visible);
- }
- };
- domainModelFilePage.setTitle(Messages.UMLCreationWizard_DomainModelFilePageTitle);
- domainModelFilePage.setDescription(Messages.UMLCreationWizard_DomainModelFilePageDescription);
- addPage(domainModelFilePage);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean performFinish() {
- IRunnableWithProgress op = new WorkspaceModifyOperation(null) {
-
- @Override
- protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException {
- diagram = UMLDiagramEditorUtil.createDiagram(diagramModelFilePage.getURI(), domainModelFilePage.getURI(), monitor);
- if (isOpenNewlyCreatedDiagramEditor() && diagram != null) {
- try {
- UMLDiagramEditorUtil.openDiagram(diagram);
- } catch (PartInitException e) {
- ErrorDialog.openError(getContainer().getShell(), Messages.UMLCreationWizardOpenEditorError, null, e.getStatus());
- }
- }
- }
- };
- try {
- getContainer().run(false, true, op);
- } catch (InterruptedException e) {
- return false;
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof CoreException) {
- ErrorDialog.openError(getContainer().getShell(), Messages.UMLCreationWizardCreationError, null, ((CoreException) e.getTargetException()).getStatus());
- } else {
- UMLDiagramEditorPlugin.getInstance().logError("Error creating diagram", e.getTargetException()); //$NON-NLS-1$
- }
- return false;
- }
- return diagram != null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+/**
+ * @generated
+ */
+public class UMLCreationWizard extends Wizard implements INewWizard {
+
+ /**
+ * @generated
+ */
+ private IWorkbench workbench;
+
+ /**
+ * @generated
+ */
+ protected IStructuredSelection selection;
+
+ /**
+ * @generated
+ */
+ protected UMLCreationWizardPage diagramModelFilePage;
+
+ /**
+ * @generated
+ */
+ protected UMLCreationWizardPage domainModelFilePage;
+
+ /**
+ * @generated
+ */
+ protected Resource diagram;
+
+ /**
+ * @generated
+ */
+ private boolean openNewlyCreatedDiagramEditor = true;
+
+ /**
+ * @generated
+ */
+ public IWorkbench getWorkbench() {
+ return workbench;
+ }
+
+ /**
+ * @generated
+ */
+ public IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ /**
+ * @generated
+ */
+ public final Resource getDiagram() {
+ return diagram;
+ }
+
+ /**
+ * @generated
+ */
+ public final boolean isOpenNewlyCreatedDiagramEditor() {
+ return openNewlyCreatedDiagramEditor;
+ }
+
+ /**
+ * @generated
+ */
+ public void setOpenNewlyCreatedDiagramEditor(boolean openNewlyCreatedDiagramEditor) {
+ this.openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor;
+ }
+
+ /**
+ * @generated
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ setWindowTitle(Messages.UMLCreationWizardTitle);
+ setDefaultPageImageDescriptor(UMLDiagramEditorPlugin.getBundledImageDescriptor("icons/wizban/NewUMLWizard.gif")); //$NON-NLS-1$
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void addPages() {
+ diagramModelFilePage = new UMLCreationWizardPage("DiagramModelFile", getSelection(), "PapyrusUMLProfile_diagram"); //$NON-NLS-1$ //$NON-NLS-2$
+ diagramModelFilePage.setTitle(Messages.UMLCreationWizard_DiagramModelFilePageTitle);
+ diagramModelFilePage.setDescription(Messages.UMLCreationWizard_DiagramModelFilePageDescription);
+ addPage(diagramModelFilePage);
+ domainModelFilePage = new UMLCreationWizardPage("DomainModelFile", getSelection(), "PapyrusUMLProfile") { //$NON-NLS-1$ //$NON-NLS-2$
+
+ public void setVisible(boolean visible) {
+ if (visible) {
+ String fileName = diagramModelFilePage.getFileName();
+ fileName = fileName.substring(0, fileName.length() - ".PapyrusUMLProfile_diagram".length()); //$NON-NLS-1$
+ setFileName(UMLDiagramEditorUtil.getUniqueFileName(
+ getContainerFullPath(), fileName, "PapyrusUMLProfile")); //$NON-NLS-1$
+ }
+ super.setVisible(visible);
+ }
+ };
+ domainModelFilePage.setTitle(Messages.UMLCreationWizard_DomainModelFilePageTitle);
+ domainModelFilePage.setDescription(Messages.UMLCreationWizard_DomainModelFilePageDescription);
+ addPage(domainModelFilePage);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean performFinish() {
+ IRunnableWithProgress op =
+ new WorkspaceModifyOperation(null) {
+
+ protected void execute(IProgressMonitor monitor)
+ throws CoreException, InterruptedException {
+ diagram = UMLDiagramEditorUtil.createDiagram(diagramModelFilePage.getURI(),
+ domainModelFilePage.getURI(),
+ monitor);
+ if (isOpenNewlyCreatedDiagramEditor() && diagram != null) {
+ try {
+ UMLDiagramEditorUtil.openDiagram(diagram);
+ } catch (PartInitException e) {
+ ErrorDialog.openError(getContainer().getShell(),
+ Messages.UMLCreationWizardOpenEditorError, null, e.getStatus());
+ }
+ }
+ }
+ };
+ try {
+ getContainer().run(false, true, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ if (e.getTargetException() instanceof CoreException) {
+ ErrorDialog.openError(getContainer().getShell(),
+ Messages.UMLCreationWizardCreationError, null,
+ ((CoreException) e.getTargetException()).getStatus());
+ } else {
+ UMLDiagramEditorPlugin.getInstance().logError("Error creating diagram", e.getTargetException()); //$NON-NLS-1$
+ }
+ return false;
+ }
+ return diagram != null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLCreationWizardPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLCreationWizardPage.java
index 36b4d6fa637..5fc2dc0f37c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLCreationWizardPage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLCreationWizardPage.java
@@ -1,96 +1,98 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-
-/**
- * @generated
- */
-public class UMLCreationWizardPage extends WizardNewFileCreationPage {
-
- /**
- * @generated
- */
- private final String fileExtension;
-
- /**
- * @generated
- */
- public UMLCreationWizardPage(String pageName, IStructuredSelection selection, String fileExtension) {
- super(pageName, selection);
- this.fileExtension = fileExtension;
- }
-
- /**
- * Override to create files with this extension.
- *
- * @generated
- */
- protected String getExtension() {
- return fileExtension;
- }
-
- /**
- * @generated
- */
- public URI getURI() {
- return URI.createPlatformResourceURI(getFilePath().toString(), false);
- }
-
- /**
- * @generated
- */
- protected IPath getFilePath() {
- IPath path = getContainerFullPath();
- if (path == null) {
- path = new Path(""); //$NON-NLS-1$
- }
- String fileName = getFileName();
- if (fileName != null) {
- path = path.append(fileName);
- }
- return path;
- }
-
- /**
- * @generated
- */
- @Override
- public void createControl(Composite parent) {
- super.createControl(parent);
- setFileName(UMLDiagramEditorUtil.getUniqueFileName(getContainerFullPath(), getFileName(), getExtension()));
- setPageComplete(validatePage());
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean validatePage() {
- if (!super.validatePage()) {
- return false;
- }
- String extension = getExtension();
- if (extension != null && !getFilePath().toString().endsWith("." + extension)) {
- setErrorMessage(NLS.bind(Messages.UMLCreationWizardPageExtensionError, extension));
- return false;
- }
- return true;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+/**
+ * @generated
+ */
+public class UMLCreationWizardPage extends WizardNewFileCreationPage {
+
+ /**
+ * @generated
+ */
+ private final String fileExtension;
+
+ /**
+ * @generated
+ */
+ public UMLCreationWizardPage(String pageName, IStructuredSelection selection, String fileExtension) {
+ super(pageName, selection);
+ this.fileExtension = fileExtension;
+ }
+
+ /**
+ * Override to create files with this extension.
+ *
+ * @generated
+ */
+ protected String getExtension() {
+ return fileExtension;
+ }
+
+ /**
+ * @generated
+ */
+ public URI getURI() {
+ return URI.createPlatformResourceURI(getFilePath().toString(), false);
+ }
+
+ /**
+ * @generated
+ */
+ protected IPath getFilePath() {
+ IPath path = getContainerFullPath();
+ if (path == null) {
+ path = new Path(""); //$NON-NLS-1$
+ }
+ String fileName = getFileName();
+ if (fileName != null) {
+ path = path.append(fileName);
+ }
+ return path;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ setFileName(UMLDiagramEditorUtil.getUniqueFileName(
+ getContainerFullPath(), getFileName(), getExtension()));
+ setPageComplete(validatePage());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean validatePage() {
+ if (!super.validatePage()) {
+ return false;
+ }
+ String extension = getExtension();
+ if (extension != null && !getFilePath().toString().endsWith("." + extension)) {
+ setErrorMessage(NLS.bind(
+ Messages.UMLCreationWizardPageExtensionError, extension));
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramContentInitializer.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramContentInitializer.java
index 8611b7e34f9..973396b9ab3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramContentInitializer.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramContentInitializer.java
@@ -1,763 +1,824 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-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;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ShortCutDiagramEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPartCN;
-import org.eclipse.uml2.uml.Profile;
-
-/**
- * @generated
- */
-public class UMLDiagramContentInitializer {
-
- /**
- * @generated
- */
- private Map myDomain2NotationMap = new HashMap();
-
- /**
- * @generated
- */
- private Collection myLinkDescriptors = new LinkedList();
-
- /**
- * @generated
- */
- public void initDiagramContent(Diagram diagram) {
- if (!ProfileDiagramEditPart.MODEL_ID.equals(diagram.getType())) {
- UMLDiagramEditorPlugin.getInstance().logError("Incorrect diagram passed as a parameter: " + diagram.getType());
- return;
- }
- if (false == diagram.getElement() instanceof Profile) {
- UMLDiagramEditorPlugin.getInstance().logError("Incorrect diagram element specified: " + diagram.getElement() + " instead of Profile");
- return;
- }
- createProfile_1000Children(diagram);
- createLinks(diagram);
- }
-
- /**
- * @generated
- */
- private void createProfile_1000Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getProfile_1000SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createDependency_2014Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getDependency_2014OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createAssociation_2015Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getAssociation_2015OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createStereotype_1026Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getStereotype_1026OutgoingLinks(view));
- createStereotypeAttributes_1071Children(getCompartment(view, StereotypeAttributeCompartmentEditPart.VISUAL_ID));
- createStereotypeOperations_1019Children(getCompartment(view, StereotypeOperationCompartmentEditPart.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createClass_2008Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getClass_2008OutgoingLinks(view));
- createClassOperations_7018Children(getCompartment(view, ClassOperationCompartmentEditPart.VISUAL_ID));
- createClassAttributes_7017Children(getCompartment(view, ClassAttributeCompartmentEditPart.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createClass_1031Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getClass_1031OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createComment_1002Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getComment_1002OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createConstraint_1014Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getConstraint_1014OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createModel_2005Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getModel_2005OutgoingLinks(view));
- createModelPackagedelements_1057Children(getCompartment(view, ModelPackageableElementCompartmentEditPartTN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createProfile_1030Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getProfile_1030OutgoingLinks(view));
- createProfilePackagedelements_1042Children(getCompartment(view, ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createPackage_2007Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getPackage_2007OutgoingLinks(view));
- createPackagePackagedelements_1005Children(getCompartment(view, PackagePackageableElementCompartmentEditPart.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createEnumeration_2006Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getEnumeration_2006OutgoingLinks(view));
- createEnumerationLiterals_1063Children(getCompartment(view, EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createPrimitiveType_2009Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getPrimitiveType_2009OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createDataType_2010Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getDataType_2010OutgoingLinks(view));
- createDataTypeAttributes_1067Children(getCompartment(view, DataTypeAttributeCompartmentEditPart.VISUAL_ID));
- createDataTypeOperations_1068Children(getCompartment(view, DataTypeOperationCompartmentEditPart.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createDiagram_2016Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getDiagram_2016OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createPrimitiveType_3026Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getPrimitiveType_3026OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createOperation_3019Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getOperation_3019OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createEnumerationLiteral_1037Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getEnumerationLiteral_1037OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createProperty_3018Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getProperty_3018OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createProperty_3002Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getProperty_3002OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createOperation_3020Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getOperation_3020OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createStereotype_1023Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getStereotype_1023OutgoingLinks(view));
- createStereotypeAttributes_1052Children(getCompartment(view, StereotypeAttributeCompartmentEditPartCN.VISUAL_ID));
- createStereotypeOperations_1053Children(getCompartment(view, StereotypeOperationCompartmentEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createClass_3010Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getClass_3010OutgoingLinks(view));
- createClassAttributes_7011Children(getCompartment(view, ClassAttributeCompartmentEditPartCN.VISUAL_ID));
- createClassOperations_7012Children(getCompartment(view, ClassOperationCompartmentEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createClass_3028Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getClass_3028OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createComment_1007Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getComment_1007OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createModel_1027Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getModel_1027OutgoingLinks(view));
- createModelPackagedelements_1058Children(getCompartment(view, ModelPackageableElementCompartmentEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createProfile_1024Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getProfile_1024OutgoingLinks(view));
- createProfilePackagedelements_1051Children(getCompartment(view, ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createPackage_1012Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getPackage_1012OutgoingLinks(view));
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getPackage_1012SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- createPackagePackagedelements_11Children(getCompartment(view, PackagePackageableElementCompartmentEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createConstraint_1028Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getConstraint_1028OutgoingLinks(view));
- }
-
- /**
- * @generated
- */
- private void createEnumeration_3025Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getEnumeration_3025OutgoingLinks(view));
- createEnumerationLiterals_1062Children(getCompartment(view, EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createDataType_3027Children(View view) {
- myDomain2NotationMap.put(view.getElement(), view);
- myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getDataType_3027OutgoingLinks(view));
- createDataTypeAttributes_1069Children(getCompartment(view, DataTypeAttributeCompartmentEditPartCN.VISUAL_ID));
- createDataTypeOperations_1070Children(getCompartment(view, DataTypeOperationCompartmentEditPartCN.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- private void createPackagePackagedelements_1005Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getPackagePackagedelements_1005SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createPackagePackagedelements_11Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getPackagePackagedelements_11SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createProfilePackagedelements_1042Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getProfilePackagedelements_1042SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createProfilePackagedelements_1051Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getProfilePackagedelements_1051SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createStereotypeAttributes_1071Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getStereotypeAttributes_1071SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createStereotypeAttributes_1052Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getStereotypeAttributes_1052SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createStereotypeOperations_1019Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getStereotypeOperations_1019SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createStereotypeOperations_1053Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getStereotypeOperations_1053SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createModelPackagedelements_1057Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getModelPackagedelements_1057SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createModelPackagedelements_1058Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getModelPackagedelements_1058SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createEnumerationLiterals_1062Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getEnumerationLiterals_1062SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createEnumerationLiterals_1063Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getEnumerationLiterals_1063SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createDataTypeAttributes_1067Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getDataTypeAttributes_1067SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createDataTypeAttributes_1069Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getDataTypeAttributes_1069SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createDataTypeOperations_1068Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getDataTypeOperations_1068SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createDataTypeOperations_1070Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getDataTypeOperations_1070SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createClassAttributes_7017Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getClassAttributes_7017SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createClassAttributes_7011Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getClassAttributes_7011SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createClassOperations_7018Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getClassOperations_7018SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createClassOperations_7012Children(View view) {
- Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE.getClassOperations_7012SemanticChildren(view);
- for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
- createNode(view, (UMLNodeDescriptor) it.next());
- }
- }
-
- /**
- * @generated
- */
- private void createNode(View parentView, UMLNodeDescriptor nodeDescriptor) {
- final String nodeType = UMLVisualIDRegistry.getType(nodeDescriptor.getVisualID());
- Node node = ViewService.createNode(parentView, nodeDescriptor.getModelElement(), nodeType, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
- switch (nodeDescriptor.getVisualID()) {
- case DependencyNodeEditPart.VISUAL_ID:
- createDependency_2014Children(node);
- return;
- case AssociationNodeEditPart.VISUAL_ID:
- createAssociation_2015Children(node);
- return;
- case StereotypeEditPart.VISUAL_ID:
- createStereotype_1026Children(node);
- return;
- case ClassEditPart.VISUAL_ID:
- createClass_2008Children(node);
- return;
- case MetaclassEditPart.VISUAL_ID:
- createClass_1031Children(node);
- return;
- case CommentEditPart.VISUAL_ID:
- createComment_1002Children(node);
- return;
- case ConstraintEditPart.VISUAL_ID:
- createConstraint_1014Children(node);
- return;
- case ModelEditPartTN.VISUAL_ID:
- createModel_2005Children(node);
- return;
- case ProfileEditPartTN.VISUAL_ID:
- createProfile_1030Children(node);
- return;
- case PackageEditPart.VISUAL_ID:
- createPackage_2007Children(node);
- return;
- case EnumerationEditPart.VISUAL_ID:
- createEnumeration_2006Children(node);
- return;
- case PrimitiveTypeEditPart.VISUAL_ID:
- createPrimitiveType_2009Children(node);
- return;
- case DataTypeEditPart.VISUAL_ID:
- createDataType_2010Children(node);
- return;
- case ShortCutDiagramEditPart.VISUAL_ID:
- createDiagram_2016Children(node);
- return;
- case PrimitiveTypeEditPartCN.VISUAL_ID:
- createPrimitiveType_3026Children(node);
- return;
- case DataTypeOperationEditPart.VISUAL_ID:
- createOperation_3019Children(node);
- return;
- case EnumerationLiteralEditPart.VISUAL_ID:
- createEnumerationLiteral_1037Children(node);
- return;
- case DataTypePropertyEditPart.VISUAL_ID:
- createProperty_3018Children(node);
- return;
- case ClassPropertyEditPart.VISUAL_ID:
- createProperty_3002Children(node);
- return;
- case ClassOperationEditPart.VISUAL_ID:
- createOperation_3020Children(node);
- return;
- case StereotypeEditPartCN.VISUAL_ID:
- createStereotype_1023Children(node);
- return;
- case ClassEditPartCN.VISUAL_ID:
- createClass_3010Children(node);
- return;
- case MetaclassEditPartCN.VISUAL_ID:
- createClass_3028Children(node);
- return;
- case CommentEditPartCN.VISUAL_ID:
- createComment_1007Children(node);
- return;
- case ModelEditPartCN.VISUAL_ID:
- createModel_1027Children(node);
- return;
- case ProfileEditPartCN.VISUAL_ID:
- createProfile_1024Children(node);
- return;
- case PackageEditPartCN.VISUAL_ID:
- createPackage_1012Children(node);
- return;
- case ConstraintEditPartCN.VISUAL_ID:
- createConstraint_1028Children(node);
- return;
- case EnumerationEditPartCN.VISUAL_ID:
- createEnumeration_3025Children(node);
- return;
- case DataTypeEditPartCN.VISUAL_ID:
- createDataType_3027Children(node);
- return;
- }
- }
-
- /**
- * @generated
- */
- private void createLinks(Diagram diagram) {
- for (boolean continueLinkCreation = true; continueLinkCreation;) {
- continueLinkCreation = false;
- Collection additionalDescriptors = new LinkedList();
- for (Iterator it = myLinkDescriptors.iterator(); it.hasNext();) {
- UMLLinkDescriptor nextLinkDescriptor = (UMLLinkDescriptor) it.next();
- if (!myDomain2NotationMap.containsKey(nextLinkDescriptor.getSource()) || !myDomain2NotationMap.containsKey(nextLinkDescriptor.getDestination())) {
- continue;
- }
- final String linkType = UMLVisualIDRegistry.getType(nextLinkDescriptor.getVisualID());
- Edge edge = ViewService.getInstance().createEdge(nextLinkDescriptor.getSemanticAdapter(), diagram, linkType, ViewUtil.APPEND, true, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
- if (edge != null) {
- edge.setSource((View) myDomain2NotationMap.get(nextLinkDescriptor.getSource()));
- edge.setTarget((View) myDomain2NotationMap.get(nextLinkDescriptor.getDestination()));
- it.remove();
- if (nextLinkDescriptor.getModelElement() != null) {
- myDomain2NotationMap.put(nextLinkDescriptor.getModelElement(), edge);
- }
- continueLinkCreation = true;
- switch (nextLinkDescriptor.getVisualID()) {
- case ExtensionEditPart.VISUAL_ID:
- additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getExtension_1013OutgoingLinks(edge));
- break;
- case AssociationEditPart.VISUAL_ID:
- additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getAssociation_4001OutgoingLinks(edge));
- break;
- case ProfileApplicationEditPart.VISUAL_ID:
- additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getProfileApplication_1045OutgoingLinks(edge));
- break;
- case AssociationBranchEditPart.VISUAL_ID:
- additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getAssociation_4019OutgoingLinks(edge));
- break;
- case GeneralizationEditPart.VISUAL_ID:
- additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getGeneralization_4002OutgoingLinks(edge));
- break;
- case DependencyEditPart.VISUAL_ID:
- additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getDependency_4008OutgoingLinks(edge));
- break;
- case DependencyBranchEditPart.VISUAL_ID:
- additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getDependency_4018OutgoingLinks(edge));
- break;
- case ElementImportEditPart.VISUAL_ID:
- additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getElementImport_1064OutgoingLinks(edge));
- break;
- case PackageImportEditPart.VISUAL_ID:
- additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE.getPackageImport_1065OutgoingLinks(edge));
- break;
- }
- }
- }
- myLinkDescriptors.addAll(additionalDescriptors);
- }
- }
-
- /**
- * @generated
- */
- private Node getCompartment(View node, int visualID) {
- String type = UMLVisualIDRegistry.getType(visualID);
- for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
- View nextView = (View) it.next();
- if (nextView instanceof Node && type.equals(nextView.getType())) {
- return (Node) nextView;
- }
- }
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+
+import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+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;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ShortCutDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPartCN;
+import org.eclipse.uml2.uml.Profile;
+
+/**
+ * @generated
+ */
+public class UMLDiagramContentInitializer {
+
+ /**
+ * @generated
+ */
+ private Map myDomain2NotationMap = new HashMap();
+
+ /**
+ * @generated
+ */
+ private Collection myLinkDescriptors = new LinkedList();
+
+ /**
+ * @generated
+ */
+ public void initDiagramContent(Diagram diagram) {
+ if (!ProfileDiagramEditPart.MODEL_ID.equals(diagram.getType())) {
+ UMLDiagramEditorPlugin.getInstance().logError("Incorrect diagram passed as a parameter: " + diagram.getType());
+ return;
+ }
+ if (false == diagram.getElement() instanceof Profile) {
+ UMLDiagramEditorPlugin.getInstance().logError("Incorrect diagram element specified: " + diagram.getElement() + " instead of Profile");
+ return;
+ }
+ createProfile_1000Children(diagram);
+ createLinks(diagram);
+ }
+
+ /**
+ * @generated
+ */
+ private void createProfile_1000Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getProfile_1000SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createDependency_2014Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getDependency_2014OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createAssociation_2015Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getAssociation_2015OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createStereotype_1026Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getStereotype_1026OutgoingLinks(view));
+ createStereotypeAttributes_1071Children(getCompartment(view, StereotypeAttributeCompartmentEditPart.VISUAL_ID));
+ createStereotypeOperations_1019Children(getCompartment(view, StereotypeOperationCompartmentEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createClass_2008Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getClass_2008OutgoingLinks(view));
+ createClassOperations_7018Children(getCompartment(view, ClassOperationCompartmentEditPart.VISUAL_ID));
+ createClassAttributes_7017Children(getCompartment(view, ClassAttributeCompartmentEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createClass_1031Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getClass_1031OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createComment_1002Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getComment_1002OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createConstraint_1014Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getConstraint_1014OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createModel_2005Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getModel_2005OutgoingLinks(view));
+ createModelPackagedelements_1057Children(getCompartment(view, ModelPackageableElementCompartmentEditPartTN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createProfile_1030Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getProfile_1030OutgoingLinks(view));
+ createProfilePackagedelements_1042Children(getCompartment(view, ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createPackage_2007Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getPackage_2007OutgoingLinks(view));
+ createPackagePackagedelements_1005Children(getCompartment(view, PackagePackageableElementCompartmentEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createEnumeration_2006Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getEnumeration_2006OutgoingLinks(view));
+ createEnumerationLiterals_1063Children(getCompartment(view, EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createPrimitiveType_2009Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getPrimitiveType_2009OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createDataType_2010Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getDataType_2010OutgoingLinks(view));
+ createDataTypeAttributes_1067Children(getCompartment(view, DataTypeAttributeCompartmentEditPart.VISUAL_ID));
+ createDataTypeOperations_1068Children(getCompartment(view, DataTypeOperationCompartmentEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createDiagram_2016Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getDiagram_2016OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createPrimitiveType_3026Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getPrimitiveType_3026OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createOperation_3019Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getOperation_3019OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createEnumerationLiteral_1037Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getEnumerationLiteral_1037OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createProperty_3018Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getProperty_3018OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createProperty_3002Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getProperty_3002OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createOperation_3020Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getOperation_3020OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createStereotype_1023Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getStereotype_1023OutgoingLinks(view));
+ createStereotypeAttributes_1052Children(getCompartment(view, StereotypeAttributeCompartmentEditPartCN.VISUAL_ID));
+ createStereotypeOperations_1053Children(getCompartment(view, StereotypeOperationCompartmentEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createClass_3010Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getClass_3010OutgoingLinks(view));
+ createClassAttributes_7011Children(getCompartment(view, ClassAttributeCompartmentEditPartCN.VISUAL_ID));
+ createClassOperations_7012Children(getCompartment(view, ClassOperationCompartmentEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createClass_3028Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getClass_3028OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createComment_1007Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getComment_1007OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createModel_1027Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getModel_1027OutgoingLinks(view));
+ createModelPackagedelements_1058Children(getCompartment(view, ModelPackageableElementCompartmentEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createProfile_1024Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getProfile_1024OutgoingLinks(view));
+ createProfilePackagedelements_1051Children(getCompartment(view, ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createPackage_1012Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getPackage_1012OutgoingLinks(view));
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getPackage_1012SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ createPackagePackagedelements_11Children(getCompartment(view, PackagePackageableElementCompartmentEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createConstraint_1028Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getConstraint_1028OutgoingLinks(view));
+ }
+
+ /**
+ * @generated
+ */
+ private void createEnumeration_3025Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getEnumeration_3025OutgoingLinks(view));
+ createEnumerationLiterals_1062Children(getCompartment(view, EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createDataType_3027Children(View view) {
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getDataType_3027OutgoingLinks(view));
+ createDataTypeAttributes_1069Children(getCompartment(view, DataTypeAttributeCompartmentEditPartCN.VISUAL_ID));
+ createDataTypeOperations_1070Children(getCompartment(view, DataTypeOperationCompartmentEditPartCN.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ private void createPackagePackagedelements_1005Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getPackagePackagedelements_1005SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createPackagePackagedelements_11Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getPackagePackagedelements_11SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createProfilePackagedelements_1042Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getProfilePackagedelements_1042SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createProfilePackagedelements_1051Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getProfilePackagedelements_1051SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createStereotypeAttributes_1071Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getStereotypeAttributes_1071SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createStereotypeAttributes_1052Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getStereotypeAttributes_1052SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createStereotypeOperations_1019Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getStereotypeOperations_1019SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createStereotypeOperations_1053Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getStereotypeOperations_1053SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createModelPackagedelements_1057Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getModelPackagedelements_1057SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createModelPackagedelements_1058Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getModelPackagedelements_1058SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createEnumerationLiterals_1062Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getEnumerationLiterals_1062SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createEnumerationLiterals_1063Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getEnumerationLiterals_1063SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createDataTypeAttributes_1067Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getDataTypeAttributes_1067SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createDataTypeAttributes_1069Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getDataTypeAttributes_1069SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createDataTypeOperations_1068Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getDataTypeOperations_1068SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createDataTypeOperations_1070Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getDataTypeOperations_1070SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createClassAttributes_7017Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getClassAttributes_7017SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createClassAttributes_7011Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getClassAttributes_7011SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createClassOperations_7018Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getClassOperations_7018SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createClassOperations_7012Children(View view) {
+ Collection childNodeDescriptors = UMLDiagramUpdater.INSTANCE
+ .getClassOperations_7012SemanticChildren(view);
+ for (Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, (UMLNodeDescriptor) it.next());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createNode(View parentView, UMLNodeDescriptor nodeDescriptor) {
+ final String nodeType = UMLVisualIDRegistry.getType(nodeDescriptor.getVisualID());
+ Node node = ViewService.createNode(parentView, nodeDescriptor.getModelElement(), nodeType, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
+ switch (nodeDescriptor.getVisualID()) {
+ case DependencyNodeEditPart.VISUAL_ID:
+ createDependency_2014Children(node);
+ return;
+ case AssociationNodeEditPart.VISUAL_ID:
+ createAssociation_2015Children(node);
+ return;
+ case StereotypeEditPart.VISUAL_ID:
+ createStereotype_1026Children(node);
+ return;
+ case ClassEditPart.VISUAL_ID:
+ createClass_2008Children(node);
+ return;
+ case MetaclassEditPart.VISUAL_ID:
+ createClass_1031Children(node);
+ return;
+ case CommentEditPart.VISUAL_ID:
+ createComment_1002Children(node);
+ return;
+ case ConstraintEditPart.VISUAL_ID:
+ createConstraint_1014Children(node);
+ return;
+ case ModelEditPartTN.VISUAL_ID:
+ createModel_2005Children(node);
+ return;
+ case ProfileEditPartTN.VISUAL_ID:
+ createProfile_1030Children(node);
+ return;
+ case PackageEditPart.VISUAL_ID:
+ createPackage_2007Children(node);
+ return;
+ case EnumerationEditPart.VISUAL_ID:
+ createEnumeration_2006Children(node);
+ return;
+ case PrimitiveTypeEditPart.VISUAL_ID:
+ createPrimitiveType_2009Children(node);
+ return;
+ case DataTypeEditPart.VISUAL_ID:
+ createDataType_2010Children(node);
+ return;
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ createDiagram_2016Children(node);
+ return;
+ case PrimitiveTypeEditPartCN.VISUAL_ID:
+ createPrimitiveType_3026Children(node);
+ return;
+ case DataTypeOperationEditPart.VISUAL_ID:
+ createOperation_3019Children(node);
+ return;
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ createEnumerationLiteral_1037Children(node);
+ return;
+ case DataTypePropertyEditPart.VISUAL_ID:
+ createProperty_3018Children(node);
+ return;
+ case ClassPropertyEditPart.VISUAL_ID:
+ createProperty_3002Children(node);
+ return;
+ case ClassOperationEditPart.VISUAL_ID:
+ createOperation_3020Children(node);
+ return;
+ case StereotypeEditPartCN.VISUAL_ID:
+ createStereotype_1023Children(node);
+ return;
+ case ClassEditPartCN.VISUAL_ID:
+ createClass_3010Children(node);
+ return;
+ case MetaclassEditPartCN.VISUAL_ID:
+ createClass_3028Children(node);
+ return;
+ case CommentEditPartCN.VISUAL_ID:
+ createComment_1007Children(node);
+ return;
+ case ModelEditPartCN.VISUAL_ID:
+ createModel_1027Children(node);
+ return;
+ case ProfileEditPartCN.VISUAL_ID:
+ createProfile_1024Children(node);
+ return;
+ case PackageEditPartCN.VISUAL_ID:
+ createPackage_1012Children(node);
+ return;
+ case ConstraintEditPartCN.VISUAL_ID:
+ createConstraint_1028Children(node);
+ return;
+ case EnumerationEditPartCN.VISUAL_ID:
+ createEnumeration_3025Children(node);
+ return;
+ case DataTypeEditPartCN.VISUAL_ID:
+ createDataType_3027Children(node);
+ return;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void createLinks(Diagram diagram) {
+ for (boolean continueLinkCreation = true; continueLinkCreation;) {
+ continueLinkCreation = false;
+ Collection additionalDescriptors = new LinkedList();
+ for (Iterator it = myLinkDescriptors.iterator(); it.hasNext();) {
+ UMLLinkDescriptor nextLinkDescriptor = (UMLLinkDescriptor) it.next();
+ if (!myDomain2NotationMap.containsKey(nextLinkDescriptor.getSource()) || !myDomain2NotationMap.containsKey(nextLinkDescriptor.getDestination())) {
+ continue;
+ }
+ final String linkType = UMLVisualIDRegistry.getType(nextLinkDescriptor.getVisualID());
+ Edge edge = ViewService.getInstance().createEdge(nextLinkDescriptor.getSemanticAdapter(), diagram, linkType, ViewUtil.APPEND, true, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
+ if (edge != null) {
+ edge.setSource((View) myDomain2NotationMap.get(nextLinkDescriptor.getSource()));
+ edge.setTarget((View) myDomain2NotationMap.get(nextLinkDescriptor.getDestination()));
+ it.remove();
+ if (nextLinkDescriptor.getModelElement() != null) {
+ myDomain2NotationMap.put(nextLinkDescriptor.getModelElement(), edge);
+ }
+ continueLinkCreation = true;
+ switch (nextLinkDescriptor.getVisualID()) {
+ case ExtensionEditPart.VISUAL_ID:
+ additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getExtension_1013OutgoingLinks(edge));
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getAssociation_4001OutgoingLinks(edge));
+ break;
+ case ProfileApplicationEditPart.VISUAL_ID:
+ additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getProfileApplication_1045OutgoingLinks(edge));
+ break;
+ case AssociationBranchEditPart.VISUAL_ID:
+ additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getAssociation_4019OutgoingLinks(edge));
+ break;
+ case GeneralizationEditPart.VISUAL_ID:
+ additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getGeneralization_4002OutgoingLinks(edge));
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getDependency_4008OutgoingLinks(edge));
+ break;
+ case DependencyBranchEditPart.VISUAL_ID:
+ additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getDependency_4018OutgoingLinks(edge));
+ break;
+ case ElementImportEditPart.VISUAL_ID:
+ additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getElementImport_1064OutgoingLinks(edge));
+ break;
+ case PackageImportEditPart.VISUAL_ID:
+ additionalDescriptors.addAll(UMLDiagramUpdater.INSTANCE
+ .getPackageImport_1065OutgoingLinks(edge));
+ break;
+ }
+ }
+ }
+ myLinkDescriptors.addAll(additionalDescriptors);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private Node getCompartment(View node, int visualID) {
+ String type = UMLVisualIDRegistry.getType(visualID);
+ for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
+ View nextView = (View) it.next();
+ if (nextView instanceof Node && type.equals(nextView.getType())) {
+ return (Node) nextView;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditor.java
index bb39fe2c076..7b0ce8f59e7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditor.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditor.java
@@ -1,537 +1,537 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import java.util.EventObject;
-
-import org.eclipse.core.commands.operations.IUndoContext;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.GraphicalViewer;
-import org.eclipse.gef.KeyHandler;
-import org.eclipse.gef.Tool;
-import org.eclipse.gef.commands.CommandStackListener;
-import org.eclipse.gef.palette.PaletteRoot;
-import org.eclipse.gef.ui.palette.PaletteViewer;
-import org.eclipse.gef.ui.palette.PaletteViewerProvider;
-import org.eclipse.gmf.runtime.common.core.service.IProviderChangeListener;
-import org.eclipse.gmf.runtime.common.core.service.ProviderChangeEvent;
-import org.eclipse.gmf.runtime.common.ui.services.marker.MarkerNavigationService;
-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
-import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
-import org.eclipse.gmf.runtime.diagram.ui.internal.parts.PaletteToolTransferDragSourceListener;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.gmfdiag.common.GmfMultiDiagramDocumentProvider;
-import org.eclipse.papyrus.uml.diagram.common.listeners.DropTargetListener;
-import org.eclipse.papyrus.uml.diagram.common.part.PapyrusPaletteContextMenuProvider;
-import org.eclipse.papyrus.uml.diagram.common.part.PapyrusPaletteViewer;
-import org.eclipse.papyrus.uml.diagram.common.part.UmlGmfDiagramEditor;
-import org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.ide.IGotoMarker;
-import org.eclipse.ui.navigator.resources.ProjectExplorer;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.part.ShowInContext;
-
-/**
- * @generated
- */
-public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderChangeListener, IGotoMarker {
-
- /**
- * @generated
- */
- public static final String ID = "org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorID"; //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final String CONTEXT_ID = "org.eclipse.papyrus.uml.diagram.profile.ui.diagramContext"; //$NON-NLS-1$
-
- /**
- * @generated
- */
- private KeyHandler paletteKeyHandler = null;
-
- /**
- * @generated
- */
- private MouseListener paletteMouseListener = null;
-
- /**
- * @generated
- */
- private OperationHistoryDirtyState dirtyState;
-
- /**
- * @generated
- */
- private TransactionalEditingDomain editingDomain;
-
- /**
- * @generated
- */
- private IDocumentProvider documentProvider;
-
- /**
- * @generated
- */
- public UMLDiagramEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws ServiceException {
- super(servicesRegistry, diagram);
- // adds a listener to the palette service, which reacts to palette customizations
- PapyrusPaletteService.getInstance().addProviderChangeListener(this);
- // Share the same editing provider
- editingDomain = servicesRegistry.getService(TransactionalEditingDomain.class);
- documentProvider = new GmfMultiDiagramDocumentProvider(editingDomain);
- // overrides editing domain created by super constructor
- setDocumentProvider(documentProvider);
- }
-
- /**
- * @generated
- */
- @Override
- protected String getContextID() {
- return CONTEXT_ID;
- }
-
- /**
- * @generated
- */
- @Override
- protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) {
- PaletteRoot paletteRoot;
- if (existingPaletteRoot == null) {
- paletteRoot = PapyrusPaletteService.getInstance().createPalette(this, getDefaultPaletteContent());
- } else {
- PapyrusPaletteService.getInstance().updatePalette(existingPaletteRoot, this, getDefaultPaletteContent());
- paletteRoot = existingPaletteRoot;
- }
- applyCustomizationsToPalette(paletteRoot);
- return paletteRoot;
- }
-
- /**
- * @generated
- */
- @Override
- protected PreferencesHint getPreferencesHint() {
- return UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT;
- }
-
- /**
- * @generated
- */
- @Override
- public String getContributorId() {
- return UMLDiagramEditorPlugin.ID;
- }
-
- /**
- * @generated
- */
- @Override
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class type) {
- if (type == IShowInTargetList.class) {
- return new IShowInTargetList() {
-
- public String[] getShowInTargetIds() {
- return new String[] { ProjectExplorer.VIEW_ID };
- }
- };
- }
- return super.getAdapter(type);
- }
-
- /**
- * @generated
- */
- @Override
- protected final IDocumentProvider getDocumentProvider(IEditorInput input) {
- return documentProvider;
- }
-
- /**
- * @generated
- */
- @Override
- public TransactionalEditingDomain getEditingDomain() {
- return editingDomain;
- }
-
- /**
- * @generated
- */
- @Override
- protected final void setDocumentProvider(IEditorInput input) {
- // Already set in the constructor
- }
-
- /**
- * @generated
- */
- public void gotoMarker(IMarker marker) {
- MarkerNavigationService.getInstance().gotoMarker(this, marker);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isSaveAsAllowed() {
- return true;
- }
-
- /**
- * @generated
- */
- @Override
- public void doSaveAs() {
- performSaveAs(new NullProgressMonitor());
- }
-
- /**
- * @generated
- */
- @Override
- protected void performSaveAs(IProgressMonitor progressMonitor) {
- // Nothing
- }
-
- /**
- * @generated
- */
- @Override
- public ShowInContext getShowInContext() {
- return new ShowInContext(getEditorInput(), getNavigatorSelection());
- }
-
- /**
- * @generated
- */
- private ISelection getNavigatorSelection() {
- return StructuredSelection.EMPTY;
- }
-
- /**
- * @generated
- */
- @Override
- protected void configureGraphicalViewer() {
- super.configureGraphicalViewer();
- DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(this, getDiagramGraphicalViewer());
- getDiagramGraphicalViewer().setContextMenu(provider);
- getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, getDiagramGraphicalViewer());
- }
-
- /**
- * @generated
- */
- @Override
- protected TransactionalEditingDomain createEditingDomain() {
- // Already configured
- return editingDomain;
- }
-
- /**
- * @generated
- */
- @Override
- protected void configureDiagramEditDomain() {
- super.configureDiagramEditDomain();
- getDiagramEditDomain().getDiagramCommandStack().addCommandStackListener(new CommandStackListener() {
-
- public void commandStackChanged(EventObject event) {
- firePropertyChange(IEditorPart.PROP_DIRTY);
- }
- });
- }
-
- /**
- * @generated
- */
- @Override
- public void doSave(IProgressMonitor progressMonitor) {
- // The saving of the resource is done by the CoreMultiDiagramEditor
- getDirtyState().saved();
- }
-
- /**
- * @generated
- */
- protected OperationHistoryDirtyState getDirtyState() {
- if (dirtyState == null) {
- dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
- }
- return dirtyState;
- }
-
- /**
- * @generated
- */
- @Override
- protected void setUndoContext(IUndoContext context) {
- if (dirtyState != null) {
- dirtyState.dispose();
- dirtyState = null;
- }
- super.setUndoContext(context);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isDirty() {
- return getDirtyState().isDirty();
- }
-
- /**
- * @generated
- */
- public void providerChanged(ProviderChangeEvent event) {
- // update the palette if the palette service has changed
- if (PapyrusPaletteService.getInstance().equals(event.getSource())) {
- PapyrusPaletteService.getInstance().updatePalette(getPaletteViewer().getPaletteRoot(), this, getDefaultPaletteContent());
- }
- }
-
- /**
- * @generated
- */
- @Override
- public void dispose() {
- // remove palette service listener
- // remove preference listener
- PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
- if (dirtyState != null) {
- dirtyState.dispose();
- dirtyState = null;
- }
- super.dispose();
- }
-
- /**
- * @generated
- */
- protected PaletteViewer getPaletteViewer() {
- return getEditDomain().getPaletteViewer();
- }
-
- /**
- * @generated
- */
- @Override
- protected PaletteViewer constructPaletteViewer() {
- return new PapyrusPaletteViewer();
- }
-
- /**
- * @generated
- */
- @Override
- protected PaletteViewerProvider createPaletteViewerProvider() {
- getEditDomain().setPaletteRoot(createPaletteRoot(null));
- return new PaletteViewerProvider(getEditDomain()) {
-
- /**
- * Override to provide the additional behavior for the tools. Will intialize with a
- * PaletteEditPartFactory that has a TrackDragger that understand how to handle the
- * mouseDoubleClick event for shape creation tools. Also will initialize the palette
- * with a defaultTool that is the SelectToolEx that undestands how to handle the enter
- * key which will result in the creation of the shape also.
- */
- @Override
- protected void configurePaletteViewer(PaletteViewer viewer) {
- super.configurePaletteViewer(viewer);
- // customize menu...
- viewer.setContextMenu(new PapyrusPaletteContextMenuProvider(viewer));
- viewer.getKeyHandler().setParent(getPaletteKeyHandler());
- viewer.getControl().addMouseListener(getPaletteMouseListener());
- // Add a transfer drag target listener that is supported on
- // palette template entries whose template is a creation tool.
- // This will enable drag and drop of the palette shape creation
- // tools.
- viewer.addDragSourceListener(new PaletteToolTransferDragSourceListener(viewer));
- viewer.setCustomizer(createPaletteCustomizer());
- }
-
- @Override
- public PaletteViewer createPaletteViewer(Composite parent) {
- PaletteViewer pViewer = constructPaletteViewer();
- pViewer.createControl(parent);
- configurePaletteViewer(pViewer);
- hookPaletteViewer(pViewer);
- return pViewer;
- }
-
- /**
- * @return Palette Key Handler for the palette
- */
- private KeyHandler getPaletteKeyHandler() {
- if (paletteKeyHandler == null) {
- paletteKeyHandler = new KeyHandler() {
-
- /**
- * Processes a <i>key released </i> event. This method is called by the Tool
- * whenever a key is released, and the Tool is in the proper state. Override
- * to support pressing the enter key to create a shape or connection
- * (between two selected shapes)
- *
- * @param event
- * the KeyEvent
- * @return <code>true</code> if KeyEvent was handled in some way
- */
- @Override
- public boolean keyReleased(KeyEvent event) {
- if (event.keyCode == SWT.Selection) {
- Tool tool = getPaletteViewer().getActiveTool().createTool();
- if (toolSupportsAccessibility(tool)) {
- tool.keyUp(event, getDiagramGraphicalViewer());
- // deactivate current selection
- getPaletteViewer().setActiveTool(null);
- return true;
- }
- }
- return super.keyReleased(event);
- }
- };
- }
- return paletteKeyHandler;
- }
-
- /**
- * @return Palette Mouse listener for the palette
- */
- private MouseListener getPaletteMouseListener() {
- if (paletteMouseListener == null) {
- paletteMouseListener = new MouseListener() {
-
- /**
- * Flag to indicate that the current active tool should be cleared after a
- * mouse double-click event.
- */
- private boolean clearActiveTool = false;
-
- /**
- * Override to support double-clicking a palette tool entry to create a
- * shape or connection (between two selected shapes).
- *
- * @see MouseListener#mouseDoubleClick(MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- Tool tool = getPaletteViewer().getActiveTool().createTool();
- if (toolSupportsAccessibility(tool)) {
- tool.setViewer(getDiagramGraphicalViewer());
- tool.setEditDomain(getDiagramGraphicalViewer().getEditDomain());
- tool.mouseDoubleClick(e, getDiagramGraphicalViewer());
- // Current active tool should be deactivated,
- // but if it is down here it will get
- // reactivated deep in GEF palette code after
- // receiving mouse up events.
- clearActiveTool = true;
- }
- }
-
- public void mouseDown(MouseEvent e) {
- // do nothing
- }
-
- public void mouseUp(MouseEvent e) {
- // Deactivate current active tool here if a
- // double-click was handled.
- if (clearActiveTool) {
- getPaletteViewer().setActiveTool(null);
- clearActiveTool = false;
- }
- }
- };
- }
- return paletteMouseListener;
- }
- };
- }
-
- /**
- * @generated
- */
- @Override
- public GraphicalViewer getGraphicalViewer() {
- return super.getGraphicalViewer();
- }
-
- /**
- * @generated
- */
- @Override
- protected void initializeGraphicalViewer() {
- super.initializeGraphicalViewer();
- // Enable Drop
- getDiagramGraphicalViewer().addDropTargetListener(new DropTargetListener(getDiagramGraphicalViewer(), LocalSelectionTransfer.getTransfer()) {
-
- @Override
- protected Object getJavaObject(TransferData data) {
- // It is usual for the transfer data not to be set because it is available locally
- return LocalSelectionTransfer.getTransfer().getSelection();
- }
-
- @Override
- protected TransactionalEditingDomain getTransactionalEditingDomain() {
- return getEditingDomain();
- }
- });
- }
-
- /**
- * @generated
- */
- @Override
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (getSite().getPage().getActiveEditor() instanceof IMultiDiagramEditor) {
- IMultiDiagramEditor editor = (IMultiDiagramEditor) getSite().getPage().getActiveEditor();
- // If not the active editor, ignore selection changed.
- if (this.equals(editor.getActiveEditor())) {
- updateActions(getSelectionActions());
- super.selectionChanged(part, selection);
- } else {
- super.selectionChanged(part, selection);
- }
- } else {
- super.selectionChanged(part, selection);
- }
- // from
- // org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.selectionChanged(IWorkbenchPart,
- // ISelection)
- if (part == this) {
- rebuildStatusLine();
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import java.util.EventObject;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.Tool;
+import org.eclipse.gef.commands.CommandStackListener;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.ui.palette.PaletteViewer;
+import org.eclipse.gef.ui.palette.PaletteViewerProvider;
+import org.eclipse.gmf.runtime.common.core.service.IProviderChangeListener;
+import org.eclipse.gmf.runtime.common.core.service.ProviderChangeEvent;
+import org.eclipse.gmf.runtime.common.ui.services.marker.MarkerNavigationService;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
+import org.eclipse.gmf.runtime.diagram.ui.internal.parts.PaletteToolTransferDragSourceListener;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
+import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.gmfdiag.common.GmfMultiDiagramDocumentProvider;
+import org.eclipse.papyrus.uml.diagram.common.listeners.DropTargetListener;
+import org.eclipse.papyrus.uml.diagram.common.part.PapyrusPaletteContextMenuProvider;
+import org.eclipse.papyrus.uml.diagram.common.part.PapyrusPaletteViewer;
+import org.eclipse.papyrus.uml.diagram.common.part.UmlGmfDiagramEditor;
+import org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.ide.IGotoMarker;
+import org.eclipse.ui.navigator.resources.ProjectExplorer;
+import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.part.ShowInContext;
+
+/**
+ * @generated
+ */
+public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderChangeListener, IGotoMarker {
+
+ /**
+ * @generated
+ */
+ public static final String ID = "org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorID"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final String CONTEXT_ID = "org.eclipse.papyrus.uml.diagram.profile.ui.diagramContext"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ private KeyHandler paletteKeyHandler = null;
+
+ /**
+ * @generated
+ */
+ private MouseListener paletteMouseListener = null;
+
+ /**
+ * @generated
+ */
+ private OperationHistoryDirtyState dirtyState;
+
+ /**
+ * @generated
+ */
+ private TransactionalEditingDomain editingDomain;
+
+ /**
+ * @generated
+ */
+ private IDocumentProvider documentProvider;
+
+ /**
+ * @generated
+ */
+ public UMLDiagramEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws ServiceException {
+ super(servicesRegistry, diagram);
+ // adds a listener to the palette service, which reacts to palette customizations
+ PapyrusPaletteService.getInstance().addProviderChangeListener(this);
+ // Share the same editing provider
+ editingDomain = servicesRegistry.getService(TransactionalEditingDomain.class);
+ documentProvider = new GmfMultiDiagramDocumentProvider(editingDomain);
+ // overrides editing domain created by super constructor
+ setDocumentProvider(documentProvider);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getContextID() {
+ return CONTEXT_ID;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) {
+ PaletteRoot paletteRoot;
+ if (existingPaletteRoot == null) {
+ paletteRoot = PapyrusPaletteService.getInstance().createPalette(this, getDefaultPaletteContent());
+ } else {
+ PapyrusPaletteService.getInstance().updatePalette(existingPaletteRoot, this, getDefaultPaletteContent());
+ paletteRoot = existingPaletteRoot;
+ }
+ applyCustomizationsToPalette(paletteRoot);
+ return paletteRoot;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected PreferencesHint getPreferencesHint() {
+ return UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getContributorId() {
+ return UMLDiagramEditorPlugin.ID;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class type) {
+ if (type == IShowInTargetList.class) {
+ return new IShowInTargetList() {
+
+ public String[] getShowInTargetIds() {
+ return new String[] { ProjectExplorer.VIEW_ID };
+ }
+ };
+ }
+ return super.getAdapter(type);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected final IDocumentProvider getDocumentProvider(IEditorInput input) {
+ return documentProvider;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public TransactionalEditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected final void setDocumentProvider(IEditorInput input) {
+ // Already set in the constructor
+ }
+
+ /**
+ * @generated
+ */
+ public void gotoMarker(IMarker marker) {
+ MarkerNavigationService.getInstance().gotoMarker(this, marker);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void doSaveAs() {
+ performSaveAs(new NullProgressMonitor());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void performSaveAs(IProgressMonitor progressMonitor) {
+ // Nothing
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public ShowInContext getShowInContext() {
+ return new ShowInContext(getEditorInput(), getNavigatorSelection());
+ }
+
+ /**
+ * @generated
+ */
+ private ISelection getNavigatorSelection() {
+ return StructuredSelection.EMPTY;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void configureGraphicalViewer() {
+ super.configureGraphicalViewer();
+ DiagramEditorContextMenuProvider provider =
+ new DiagramEditorContextMenuProvider(this, getDiagramGraphicalViewer());
+ getDiagramGraphicalViewer().setContextMenu(provider);
+ getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, getDiagramGraphicalViewer());
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected TransactionalEditingDomain createEditingDomain() {
+ // Already configured
+ return editingDomain;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void configureDiagramEditDomain() {
+ super.configureDiagramEditDomain();
+ getDiagramEditDomain().getDiagramCommandStack().addCommandStackListener(new CommandStackListener() {
+
+ public void commandStackChanged(EventObject event) {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void doSave(IProgressMonitor progressMonitor) {
+ // The saving of the resource is done by the CoreMultiDiagramEditor
+ getDirtyState().saved();
+ }
+
+ /**
+ * @generated
+ */
+ protected OperationHistoryDirtyState getDirtyState() {
+ if (dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setUndoContext(IUndoContext context) {
+ if (dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+ super.setUndoContext(context);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isDirty() {
+ return getDirtyState().isDirty();
+ }
+
+ /**
+ * @generated
+ */
+ public void providerChanged(ProviderChangeEvent event) {
+ // update the palette if the palette service has changed
+ if (PapyrusPaletteService.getInstance().equals(event.getSource())) {
+ PapyrusPaletteService.getInstance().updatePalette(getPaletteViewer().getPaletteRoot(), this,
+ getDefaultPaletteContent());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void dispose() {
+ // remove palette service listener
+ // remove preference listener
+ PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+ if (dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+ super.dispose();
+ }
+
+ /**
+ * @generated
+ */
+ protected PaletteViewer getPaletteViewer() {
+ return getEditDomain().getPaletteViewer();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected PaletteViewer constructPaletteViewer() {
+ return new PapyrusPaletteViewer();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected PaletteViewerProvider createPaletteViewerProvider() {
+ getEditDomain().setPaletteRoot(createPaletteRoot(null));
+ return new PaletteViewerProvider(getEditDomain()) {
+
+ /**
+ * Override to provide the additional behavior for the tools. Will intialize with a
+ * PaletteEditPartFactory that has a TrackDragger that understand how to handle the
+ * mouseDoubleClick event for shape creation tools. Also will initialize the palette
+ * with a defaultTool that is the SelectToolEx that undestands how to handle the enter
+ * key which will result in the creation of the shape also.
+ */
+ protected void configurePaletteViewer(PaletteViewer viewer) {
+ super.configurePaletteViewer(viewer);
+ // customize menu...
+ viewer.setContextMenu(new PapyrusPaletteContextMenuProvider(viewer));
+ viewer.getKeyHandler().setParent(getPaletteKeyHandler());
+ viewer.getControl().addMouseListener(getPaletteMouseListener());
+ // Add a transfer drag target listener that is supported on
+ // palette template entries whose template is a creation tool.
+ // This will enable drag and drop of the palette shape creation
+ // tools.
+ viewer.addDragSourceListener(new PaletteToolTransferDragSourceListener(viewer));
+ viewer.setCustomizer(createPaletteCustomizer());
+ }
+
+ public PaletteViewer createPaletteViewer(Composite parent) {
+ PaletteViewer pViewer = constructPaletteViewer();
+ pViewer.createControl(parent);
+ configurePaletteViewer(pViewer);
+ hookPaletteViewer(pViewer);
+ return pViewer;
+ }
+
+ /**
+ * @return Palette Key Handler for the palette
+ */
+ private KeyHandler getPaletteKeyHandler() {
+ if (paletteKeyHandler == null) {
+ paletteKeyHandler = new KeyHandler() {
+
+ /**
+ * Processes a <i>key released </i> event. This method is called by the Tool
+ * whenever a key is released, and the Tool is in the proper state. Override
+ * to support pressing the enter key to create a shape or connection
+ * (between two selected shapes)
+ *
+ * @param event
+ * the KeyEvent
+ * @return <code>true</code> if KeyEvent was handled in some way
+ */
+ public boolean keyReleased(KeyEvent event) {
+ if (event.keyCode == SWT.Selection) {
+ Tool tool = getPaletteViewer().getActiveTool().createTool();
+ if (toolSupportsAccessibility(tool)) {
+ tool.keyUp(event, getDiagramGraphicalViewer());
+ // deactivate current selection
+ getPaletteViewer().setActiveTool(null);
+ return true;
+ }
+ }
+ return super.keyReleased(event);
+ }
+ };
+ }
+ return paletteKeyHandler;
+ }
+
+ /**
+ * @return Palette Mouse listener for the palette
+ */
+ private MouseListener getPaletteMouseListener() {
+ if (paletteMouseListener == null) {
+ paletteMouseListener = new MouseListener() {
+
+ /**
+ * Flag to indicate that the current active tool should be cleared after a
+ * mouse double-click event.
+ */
+ private boolean clearActiveTool = false;
+
+ /**
+ * Override to support double-clicking a palette tool entry to create a
+ * shape or connection (between two selected shapes).
+ *
+ * @see MouseListener#mouseDoubleClick(MouseEvent)
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+ Tool tool = getPaletteViewer().getActiveTool().createTool();
+ if (toolSupportsAccessibility(tool)) {
+ tool.setViewer(getDiagramGraphicalViewer());
+ tool.setEditDomain(getDiagramGraphicalViewer().getEditDomain());
+ tool.mouseDoubleClick(e, getDiagramGraphicalViewer());
+ // Current active tool should be deactivated,
+ // but if it is down here it will get
+ // reactivated deep in GEF palette code after
+ // receiving mouse up events.
+ clearActiveTool = true;
+ }
+ }
+
+ public void mouseDown(MouseEvent e) {
+ // do nothing
+ }
+
+ public void mouseUp(MouseEvent e) {
+ // Deactivate current active tool here if a
+ // double-click was handled.
+ if (clearActiveTool) {
+ getPaletteViewer().setActiveTool(null);
+ clearActiveTool = false;
+ }
+ }
+ };
+ }
+ return paletteMouseListener;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public GraphicalViewer getGraphicalViewer() {
+ return super.getGraphicalViewer();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void initializeGraphicalViewer() {
+ super.initializeGraphicalViewer();
+ // Enable Drop
+ getDiagramGraphicalViewer().addDropTargetListener(
+ new DropTargetListener(getDiagramGraphicalViewer(), LocalSelectionTransfer.getTransfer()) {
+
+ @Override
+ protected Object getJavaObject(TransferData data) {
+ // It is usual for the transfer data not to be set because it is available locally
+ return LocalSelectionTransfer.getTransfer().getSelection();
+ }
+
+ @Override
+ protected TransactionalEditingDomain getTransactionalEditingDomain() {
+ return getEditingDomain();
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (getSite().getPage().getActiveEditor() instanceof IMultiDiagramEditor) {
+ IMultiDiagramEditor editor = (IMultiDiagramEditor) getSite().getPage().getActiveEditor();
+ // If not the active editor, ignore selection changed.
+ if (this.equals(editor.getActiveEditor())) {
+ updateActions(getSelectionActions());
+ super.selectionChanged(part, selection);
+ } else {
+ super.selectionChanged(part, selection);
+ }
+ } else {
+ super.selectionChanged(part, selection);
+ }
+ // from
+ // org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.selectionChanged(IWorkbenchPart,
+ // ISelection)
+ if (part == this) {
+ rebuildStatusLine();
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditorPlugin.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditorPlugin.java
index 44d706a4b89..fce6b91d3a7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditorPlugin.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditorPlugin.java
@@ -1,275 +1,280 @@
-/**
- * Copyright (c) 2014 CEA LIST and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus (CEA) - bug 410346
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.edit.provider.IItemLabelProvider;
-import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.papyrus.infra.core.log.LogHelper;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.Activator;
-import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
-import org.eclipse.papyrus.uml.diagram.profile.preferences.DiagramPreferenceInitializer;
-import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * @generated
- */
-public class UMLDiagramEditorPlugin extends AbstractUIPlugin {
-
- /**
- * @generated
- */
- public static final String ID = "org.eclipse.papyrus.uml.diagram.profile"; //$NON-NLS-1$
-
- /**
- * @generated
- */
- private LogHelper myLogHelper;
-
- /**
- * @generated
- */
- public static final PreferencesHint DIAGRAM_PREFERENCES_HINT = new PreferencesHint(ID);
-
- /**
- * @generated
- */
- private static UMLDiagramEditorPlugin instance;
-
- /**
- * @generated
- */
- private AdapterFactory adapterFactory;
-
- /**
- * @generated
- */
- private UMLDocumentProvider documentProvider;
-
- /**
- * @generated
- */
- private UMLBaseItemSemanticEditPolicy.LinkConstraints linkConstraints;
-
- /**
- * @generated
- */
- private ElementInitializers initializers;
-
- /**
- * @generated
- */
- public UMLDiagramEditorPlugin() {
- }
-
- /**
- * @generated
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- instance = this;
- myLogHelper = new LogHelper(this);
- PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT, getPreferenceStore());
- adapterFactory = org.eclipse.papyrus.infra.gmfdiag.common.Activator.getInstance().getItemProvidersAdapterFactory();
- DiagramPreferenceInitializer diagramPreferenceInitializer = new DiagramPreferenceInitializer();
- diagramPreferenceInitializer.initializeDefaultPreferences();
- }
-
- /**
- * @generated
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- adapterFactory = null;
- linkConstraints = null;
- initializers = null;
- instance = null;
- super.stop(context);
- }
-
- /**
- * @generated
- */
- public static UMLDiagramEditorPlugin getInstance() {
- return instance;
- }
-
- /**
- * @generated
- */
- @Override
- public IPreferenceStore getPreferenceStore() {
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- return store;
- }
-
- /**
- * @generated
- */
- public AdapterFactory getItemProvidersAdapterFactory() {
- return adapterFactory;
- }
-
- /**
- * @generated
- */
- public ImageDescriptor getItemImageDescriptor(Object item) {
- IItemLabelProvider labelProvider = (IItemLabelProvider) adapterFactory.adapt(item, IItemLabelProvider.class);
- if (labelProvider != null) {
- return ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(item));
- }
- return null;
- }
-
- /**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path.
- *
- * @generated
- * @param path
- * the path
- * @return the image descriptor
- */
- public static ImageDescriptor getBundledImageDescriptor(String path) {
- return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);
- }
-
- /**
- * Respects images residing in any plug-in. If path is relative,
- * then this bundle is looked up for the image, otherwise, for absolute
- * path, first segment is taken as id of plug-in with image
- *
- * @generated
- * @param path
- * the path to image, either absolute (with plug-in id as first segment), or relative for bundled images
- * @return the image descriptor
- */
- public static ImageDescriptor findImageDescriptor(String path) {
- final IPath p = new Path(path);
- if (p.isAbsolute() && p.segmentCount() > 1) {
- return AbstractUIPlugin.imageDescriptorFromPlugin(p.segment(0), p.removeFirstSegments(1).makeAbsolute().toString());
- } else {
- return getBundledImageDescriptor(p.makeAbsolute().toString());
- }
- }
-
- /**
- * Returns an image for the image file at the given plugin relative path.
- * Client do not need to dispose this image. Images will be disposed automatically.
- *
- * @generated
- * @param path
- * the path
- * @return image instance
- */
- public Image getBundledImage(String path) {
- Image image = getImageRegistry().get(path);
- if (image == null) {
- getImageRegistry().put(path, getBundledImageDescriptor(path));
- image = getImageRegistry().get(path);
- }
- return image;
- }
-
- /**
- * Returns string from plug-in's resource bundle
- *
- * @generated
- */
- public static String getString(String key) {
- return Platform.getResourceString(getInstance().getBundle(), "%" + key); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- public UMLDocumentProvider getDocumentProvider() {
- if (documentProvider == null) {
- documentProvider = new UMLDocumentProvider();
- }
- return documentProvider;
- }
-
- /**
- * @generated
- */
- public UMLBaseItemSemanticEditPolicy.LinkConstraints getLinkConstraints() {
- return linkConstraints;
- }
-
- /**
- * @generated
- */
- public void setLinkConstraints(UMLBaseItemSemanticEditPolicy.LinkConstraints lc) {
- this.linkConstraints = lc;
- }
-
- /**
- * @generated
- */
- public ElementInitializers getElementInitializers() {
- return initializers;
- }
-
- /**
- * @generated
- */
- public void setElementInitializers(ElementInitializers i) {
- this.initializers = i;
- }
-
- /**
- * @generated
- */
- public void logError(String error) {
- getLogHelper().warn(error);
- }
-
- /**
- * @generated
- */
- public void logError(String error, Throwable throwable) {
- getLogHelper().error(error, throwable);
- }
-
- /**
- * @generated
- */
- public void logInfo(String message) {
- getLogHelper().info(message);
- }
-
- /**
- * @generated
- */
- public void logInfo(String message, Throwable throwable) {
- getLogHelper().error(message, throwable);
- }
-
- /**
- * @generated
- */
- public LogHelper getLogHelper() {
- return myLogHelper;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.Activator;
+import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.preferences.DiagramPreferenceInitializer;
+import org.eclipse.papyrus.uml.diagram.profile.providers.ElementInitializers;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @generated
+ */
+public class UMLDiagramEditorPlugin extends AbstractUIPlugin {
+
+ /**
+ * @generated
+ */
+ public static final String ID = "org.eclipse.papyrus.uml.diagram.profile"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ private LogHelper myLogHelper;
+
+ /**
+ * @generated
+ */
+ public static final PreferencesHint DIAGRAM_PREFERENCES_HINT = new PreferencesHint(ID);
+
+ /**
+ * @generated
+ */
+ private static UMLDiagramEditorPlugin instance;
+
+ /**
+ * @generated
+ */
+ private AdapterFactory adapterFactory;
+
+ /**
+ * @generated
+ */
+ private UMLDocumentProvider documentProvider;
+
+ /**
+ * @generated
+ */
+ private UMLBaseItemSemanticEditPolicy.LinkConstraints linkConstraints;
+
+ /**
+ * @generated
+ */
+ private ElementInitializers initializers;
+
+ /**
+ * @generated
+ */
+ public UMLDiagramEditorPlugin() {
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ instance = this;
+ myLogHelper = new LogHelper(this);
+ PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT, getPreferenceStore());
+ adapterFactory = org.eclipse.papyrus.infra.gmfdiag.common.Activator.getInstance().getItemProvidersAdapterFactory();
+ DiagramPreferenceInitializer diagramPreferenceInitializer = new DiagramPreferenceInitializer();
+ diagramPreferenceInitializer.initializeDefaultPreferences();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ adapterFactory = null;
+ linkConstraints = null;
+ initializers = null;
+ instance = null;
+ super.stop(context);
+ }
+
+ /**
+ * @generated
+ */
+ public static UMLDiagramEditorPlugin getInstance() {
+ return instance;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IPreferenceStore getPreferenceStore() {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ return store;
+ }
+
+ /**
+ * @generated
+ */
+ public AdapterFactory getItemProvidersAdapterFactory() {
+ return adapterFactory;
+ }
+
+ /**
+ * @generated
+ */
+ public ImageDescriptor getItemImageDescriptor(Object item) {
+ IItemLabelProvider labelProvider =
+ (IItemLabelProvider) adapterFactory.adapt(
+ item, IItemLabelProvider.class);
+ if (labelProvider != null) {
+ return ExtendedImageRegistry.getInstance().getImageDescriptor(
+ labelProvider.getImage(item));
+ }
+ return null;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @generated
+ * @param path
+ * the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getBundledImageDescriptor(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);
+ }
+
+ /**
+ * Respects images residing in any plug-in. If path is relative,
+ * then this bundle is looked up for the image, otherwise, for absolute
+ * path, first segment is taken as id of plug-in with image
+ *
+ * @generated
+ * @param path
+ * the path to image, either absolute (with plug-in id as first segment), or relative for bundled images
+ * @return the image descriptor
+ */
+ public static ImageDescriptor findImageDescriptor(String path) {
+ final IPath p = new Path(path);
+ if (p.isAbsolute() && p.segmentCount() > 1) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin(
+ p.segment(0), p.removeFirstSegments(1).makeAbsolute().toString());
+ } else {
+ return getBundledImageDescriptor(p.makeAbsolute().toString());
+ }
+ }
+
+ /**
+ * Returns an image for the image file at the given plugin relative path.
+ * Client do not need to dispose this image. Images will be disposed automatically.
+ *
+ * @generated
+ * @param path
+ * the path
+ * @return image instance
+ */
+ public Image getBundledImage(String path) {
+ Image image = getImageRegistry().get(path);
+ if (image == null) {
+ getImageRegistry().put(path, getBundledImageDescriptor(path));
+ image = getImageRegistry().get(path);
+ }
+ return image;
+ }
+
+ /**
+ * Returns string from plug-in's resource bundle
+ *
+ * @generated
+ */
+ public static String getString(String key) {
+ return Platform.getResourceString(
+ getInstance().getBundle(), "%" + key); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ public UMLDocumentProvider getDocumentProvider() {
+ if (documentProvider == null) {
+ documentProvider = new UMLDocumentProvider();
+ }
+ return documentProvider;
+ }
+
+ /**
+ * @generated
+ */
+ public UMLBaseItemSemanticEditPolicy.LinkConstraints getLinkConstraints() {
+ return linkConstraints;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLinkConstraints(UMLBaseItemSemanticEditPolicy.LinkConstraints lc) {
+ this.linkConstraints = lc;
+ }
+
+ /**
+ * @generated
+ */
+ public ElementInitializers getElementInitializers() {
+ return initializers;
+ }
+
+ /**
+ * @generated
+ */
+ public void setElementInitializers(ElementInitializers i) {
+ this.initializers = i;
+ }
+
+ /**
+ * @generated
+ */
+ public void logError(String error) {
+ getLogHelper().warn(error);
+ }
+
+ /**
+ * @generated
+ */
+ public void logError(String error, Throwable throwable) {
+ getLogHelper().error(error, throwable);
+ }
+
+ /**
+ * @generated
+ */
+ public void logInfo(String message) {
+ getLogHelper().info(message);
+ }
+
+ /**
+ * @generated
+ */
+ public void logInfo(String message, Throwable throwable) {
+ getLogHelper().error(message, throwable);
+ }
+
+ /**
+ * @generated
+ */
+ public LogHelper getLogHelper() {
+ return myLogHelper;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditorUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditorUtil.java
index b0b3ed66249..c9f41818a1b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditorUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditorUtil.java
@@ -1,348 +1,349 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import java.io.IOException;
-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 java.util.Set;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.OperationHistoryFactory;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.tooling.runtime.part.DefaultDiagramEditorUtil;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.UMLFactory;
-
-/**
- * @generated
- */
-public class UMLDiagramEditorUtil {
-
- /**
- * @generated
- */
- public static Map<?, ?> getSaveOptions() {
- HashMap<String, Object> saveOptions = new HashMap<String, Object>();
- saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
- saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
- return saveOptions;
- }
-
- /**
- * @generated
- */
- public static boolean openDiagram(Resource diagram) throws PartInitException {
- String path = diagram.getURI().toPlatformString(true);
- IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
- if (workspaceResource instanceof IFile) {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- return null != page.openEditor(new FileEditorInput((IFile) workspaceResource), UMLDiagramEditor.ID);
- }
- return false;
- }
-
- /**
- * @generated
- */
- public static void setCharset(IFile file) {
- if (file == null) {
- return;
- }
- try {
- file.setCharset("UTF-8", new NullProgressMonitor()); //$NON-NLS-1$
- } catch (CoreException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Unable to set charset for file " + file.getFullPath(), e); //$NON-NLS-1$
- }
- }
-
- /**
- * @generated
- */
- public static String getUniqueFileName(IPath containerFullPath, String fileName, String extension) {
- return DefaultDiagramEditorUtil.getUniqueFileName(containerFullPath, fileName, extension, DefaultDiagramEditorUtil.EXISTS_IN_WORKSPACE);
- }
-
- /**
- * Runs the wizard in a dialog.
- *
- * @generated
- */
- public static void runWizard(Shell shell, Wizard wizard, String settingsKey) {
- IDialogSettings pluginDialogSettings = UMLDiagramEditorPlugin.getInstance().getDialogSettings();
- IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey);
- if (wizardDialogSettings == null) {
- wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey);
- }
- wizard.setDialogSettings(wizardDialogSettings);
- WizardDialog dialog = new WizardDialog(shell, wizard);
- dialog.create();
- dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);
- dialog.open();
- }
-
- /**
- * This method should be called within a workspace modify operation since it creates resources.
- *
- * @generated
- */
- public static Resource createDiagram(URI diagramURI, URI modelURI, IProgressMonitor progressMonitor) {
- TransactionalEditingDomain editingDomain = WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain();
- progressMonitor.beginTask(Messages.UMLDiagramEditorUtil_CreateDiagramProgressTask, 3);
- final Resource diagramResource = editingDomain.getResourceSet().createResource(diagramURI);
- final Resource modelResource = editingDomain.getResourceSet().createResource(modelURI);
- final String diagramName = diagramURI.lastSegment();
- AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain, Messages.UMLDiagramEditorUtil_CreateDiagramCommandLabel, Collections.EMPTY_LIST) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Profile model = createInitialModel();
- attachModelToResource(model, modelResource);
- Diagram diagram = ViewService.createDiagram(model, ProfileDiagramEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
- if (diagram != null) {
- diagramResource.getContents().add(diagram);
- diagram.setName(diagramName);
- diagram.setElement(model);
- }
- try {
- modelResource.save(org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorUtil.getSaveOptions());
- diagramResource.save(org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorUtil.getSaveOptions());
- } catch (IOException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Unable to store model and diagram resources", e); //$NON-NLS-1$
- }
- return CommandResult.newOKCommandResult();
- }
- };
- try {
- OperationHistoryFactory.getOperationHistory().execute(command, new SubProgressMonitor(progressMonitor, 1), null);
- } catch (ExecutionException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e); //$NON-NLS-1$
- }
- setCharset(WorkspaceSynchronizer.getFile(modelResource));
- setCharset(WorkspaceSynchronizer.getFile(diagramResource));
- return diagramResource;
- }
-
- /**
- * Create a new instance of domain element associated with canvas.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- private static Profile createInitialModel() {
- return UMLFactory.eINSTANCE.createProfile();
- }
-
- /**
- * Store model element in the resource.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @generated
- */
- private static void attachModelToResource(Profile model, Resource resource) {
- resource.getContents().add(model);
- }
-
- /**
- * @generated
- */
- public static void selectElementsInDiagram(IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) {
- diagramPart.getDiagramGraphicalViewer().deselectAll();
- EditPart firstPrimary = null;
- for (EditPart nextPart : editParts) {
- diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
- if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) {
- firstPrimary = nextPart;
- }
- }
- if (!editParts.isEmpty()) {
- diagramPart.getDiagramGraphicalViewer().reveal(firstPrimary != null ? firstPrimary : (EditPart) editParts.get(0));
- }
- }
-
- /**
- * @generated
- */
- private static int findElementsInDiagramByID(DiagramEditPart diagramPart, EObject element, List<EditPart> editPartCollector) {
- IDiagramGraphicalViewer viewer = (IDiagramGraphicalViewer) diagramPart.getViewer();
- final int intialNumOfEditParts = editPartCollector.size();
- if (element instanceof View) { // support notation element lookup
- EditPart editPart = (EditPart) viewer.getEditPartRegistry().get(element);
- if (editPart != null) {
- editPartCollector.add(editPart);
- return 1;
- }
- }
- String elementID = EMFCoreUtil.getProxyID(element);
- @SuppressWarnings("unchecked")
- List<EditPart> associatedParts = viewer.findEditPartsForElement(elementID, IGraphicalEditPart.class);
- // perform the possible hierarchy disjoint -> take the top-most parts only
- for (EditPart nextPart : associatedParts) {
- EditPart parentPart = nextPart.getParent();
- while (parentPart != null && !associatedParts.contains(parentPart)) {
- parentPart = parentPart.getParent();
- }
- if (parentPart == null) {
- editPartCollector.add(nextPart);
- }
- }
- if (intialNumOfEditParts == editPartCollector.size()) {
- if (!associatedParts.isEmpty()) {
- editPartCollector.add(associatedParts.get(0));
- } else {
- if (element.eContainer() != null) {
- return findElementsInDiagramByID(diagramPart, element.eContainer(), editPartCollector);
- }
- }
- }
- return editPartCollector.size() - intialNumOfEditParts;
- }
-
- /**
- * @generated
- */
- public static View findView(DiagramEditPart diagramEditPart, EObject targetElement, LazyElement2ViewMap lazyElement2ViewMap) {
- boolean hasStructuralURI = false;
- if (targetElement.eResource() instanceof XMLResource) {
- hasStructuralURI = ((XMLResource) targetElement.eResource()).getID(targetElement) == null;
- }
- View view = null;
- LinkedList<EditPart> editPartHolder = new LinkedList<EditPart>();
- if (hasStructuralURI && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) {
- view = lazyElement2ViewMap.getElement2ViewMap().get(targetElement);
- } else if (findElementsInDiagramByID(diagramEditPart, targetElement, editPartHolder) > 0) {
- EditPart editPart = editPartHolder.get(0);
- view = editPart.getModel() instanceof View ? (View) editPart.getModel() : null;
- }
- return (view == null) ? diagramEditPart.getDiagramView() : view;
- }
-
- /**
- * XXX This is quite suspicious code (especially editPartTmpHolder) and likely to be removed soon
- *
- * @generated
- */
- public static class LazyElement2ViewMap {
-
- /**
- * @generated
- */
- private Map<EObject, View> element2ViewMap;
-
- /**
- * @generated
- */
- private View scope;
-
- /**
- * @generated
- */
- private Set<? extends EObject> elementSet;
-
- /**
- * @generated
- */
- public LazyElement2ViewMap(View scope, Set<? extends EObject> elements) {
- this.scope = scope;
- this.elementSet = elements;
- }
-
- /**
- * @generated
- */
- public final Map<EObject, View> getElement2ViewMap() {
- if (element2ViewMap == null) {
- element2ViewMap = new HashMap<EObject, View>();
- // map possible notation elements to itself as these can't be found by view.getElement()
- for (EObject element : elementSet) {
- if (element instanceof View) {
- View view = (View) element;
- if (view.getDiagram() == scope.getDiagram()) {
- element2ViewMap.put(element, view); // take only those that part of our diagram
- }
- }
- }
- buildElement2ViewMap(scope, element2ViewMap, elementSet);
- }
- return element2ViewMap;
- }
-
- /**
- * @generated
- */
- private static boolean buildElement2ViewMap(View parentView, Map<EObject, View> element2ViewMap, Set<? extends EObject> elements) {
- if (elements.size() == element2ViewMap.size()) {
- return true;
- }
- if (parentView.isSetElement() && !element2ViewMap.containsKey(parentView.getElement()) && elements.contains(parentView.getElement())) {
- element2ViewMap.put(parentView.getElement(), parentView);
- if (elements.size() == element2ViewMap.size()) {
- return true;
- }
- }
- boolean complete = false;
- for (Iterator<?> it = parentView.getChildren().iterator(); it.hasNext() && !complete;) {
- complete = buildElement2ViewMap((View) it.next(), element2ViewMap, elements);
- }
- for (Iterator<?> it = parentView.getSourceEdges().iterator(); it.hasNext() && !complete;) {
- complete = buildElement2ViewMap((View) it.next(), element2ViewMap, elements);
- }
- for (Iterator<?> it = parentView.getTargetEdges().iterator(); it.hasNext() && !complete;) {
- complete = buildElement2ViewMap((View) it.next(), element2ViewMap, elements);
- }
- return complete;
- }
- } // LazyElement2ViewMap
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import java.io.IOException;
+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 java.util.Set;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.part.DefaultDiagramEditorUtil;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * @generated
+ */
+public class UMLDiagramEditorUtil {
+
+ /**
+ * @generated
+ */
+ public static Map<?, ?> getSaveOptions() {
+ HashMap<String, Object> saveOptions = new HashMap<String, Object>();
+ saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
+ saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+ return saveOptions;
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean openDiagram(Resource diagram) throws PartInitException {
+ String path = diagram.getURI().toPlatformString(true);
+ IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
+ if (workspaceResource instanceof IFile) {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ return null != page.openEditor(new FileEditorInput((IFile) workspaceResource), UMLDiagramEditor.ID);
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static void setCharset(IFile file) {
+ if (file == null) {
+ return;
+ }
+ try {
+ file.setCharset("UTF-8", new NullProgressMonitor()); //$NON-NLS-1$
+ } catch (CoreException e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Unable to set charset for file " + file.getFullPath(), e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public static String getUniqueFileName(IPath containerFullPath, String fileName, String extension) {
+ return DefaultDiagramEditorUtil.getUniqueFileName(containerFullPath, fileName, extension,
+ DefaultDiagramEditorUtil.EXISTS_IN_WORKSPACE);
+ }
+
+ /**
+ * Runs the wizard in a dialog.
+ *
+ * @generated
+ */
+ public static void runWizard(Shell shell, Wizard wizard, String settingsKey) {
+ IDialogSettings pluginDialogSettings = UMLDiagramEditorPlugin.getInstance().getDialogSettings();
+ IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey);
+ if (wizardDialogSettings == null) {
+ wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey);
+ }
+ wizard.setDialogSettings(wizardDialogSettings);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);
+ dialog.open();
+ }
+
+ /**
+ * This method should be called within a workspace modify operation since it creates resources.
+ *
+ * @generated
+ */
+ public static Resource createDiagram(URI diagramURI, URI modelURI, IProgressMonitor progressMonitor) {
+ TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain();
+ progressMonitor.beginTask(Messages.UMLDiagramEditorUtil_CreateDiagramProgressTask, 3);
+ final Resource diagramResource = editingDomain.getResourceSet().createResource(diagramURI);
+ final Resource modelResource = editingDomain.getResourceSet().createResource(modelURI);
+ final String diagramName = diagramURI.lastSegment();
+ AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain, Messages.UMLDiagramEditorUtil_CreateDiagramCommandLabel, Collections.EMPTY_LIST) {
+
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Profile model = createInitialModel();
+ attachModelToResource(model, modelResource);
+ Diagram diagram = ViewService.createDiagram(
+ model,
+ ProfileDiagramEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
+ if (diagram != null) {
+ diagramResource.getContents().add(diagram);
+ diagram.setName(diagramName);
+ diagram.setElement(model);
+ }
+ try {
+ modelResource.save(org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorUtil.getSaveOptions());
+ diagramResource.save(org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorUtil.getSaveOptions());
+ } catch (IOException e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Unable to store model and diagram resources", e); //$NON-NLS-1$
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ try {
+ OperationHistoryFactory.getOperationHistory().execute(command, new SubProgressMonitor(progressMonitor, 1), null);
+ } catch (ExecutionException e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e); //$NON-NLS-1$
+ }
+ setCharset(WorkspaceSynchronizer.getFile(modelResource));
+ setCharset(WorkspaceSynchronizer.getFile(diagramResource));
+ return diagramResource;
+ }
+
+ /**
+ * Create a new instance of domain element associated with canvas.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static Profile createInitialModel() {
+ return UMLFactory.eINSTANCE.createProfile();
+ }
+
+ /**
+ * Store model element in the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static void attachModelToResource(Profile model, Resource resource) {
+ resource.getContents().add(model);
+ }
+
+ /**
+ * @generated
+ */
+ public static void selectElementsInDiagram(IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) {
+ diagramPart.getDiagramGraphicalViewer().deselectAll();
+ EditPart firstPrimary = null;
+ for (EditPart nextPart : editParts) {
+ diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
+ if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) {
+ firstPrimary = nextPart;
+ }
+ }
+ if (!editParts.isEmpty()) {
+ diagramPart.getDiagramGraphicalViewer().reveal(firstPrimary != null ? firstPrimary : (EditPart) editParts.get(0));
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private static int findElementsInDiagramByID(DiagramEditPart diagramPart, EObject element, List<EditPart> editPartCollector) {
+ IDiagramGraphicalViewer viewer = (IDiagramGraphicalViewer) diagramPart.getViewer();
+ final int intialNumOfEditParts = editPartCollector.size();
+ if (element instanceof View) { // support notation element lookup
+ EditPart editPart = (EditPart) viewer.getEditPartRegistry().get(element);
+ if (editPart != null) {
+ editPartCollector.add(editPart);
+ return 1;
+ }
+ }
+ String elementID = EMFCoreUtil.getProxyID(element);
+ @SuppressWarnings("unchecked")
+ List<EditPart> associatedParts = viewer.findEditPartsForElement(elementID, IGraphicalEditPart.class);
+ // perform the possible hierarchy disjoint -> take the top-most parts only
+ for (EditPart nextPart : associatedParts) {
+ EditPart parentPart = nextPart.getParent();
+ while (parentPart != null && !associatedParts.contains(parentPart)) {
+ parentPart = parentPart.getParent();
+ }
+ if (parentPart == null) {
+ editPartCollector.add(nextPart);
+ }
+ }
+ if (intialNumOfEditParts == editPartCollector.size()) {
+ if (!associatedParts.isEmpty()) {
+ editPartCollector.add(associatedParts.get(0));
+ } else {
+ if (element.eContainer() != null) {
+ return findElementsInDiagramByID(diagramPart, element.eContainer(), editPartCollector);
+ }
+ }
+ }
+ return editPartCollector.size() - intialNumOfEditParts;
+ }
+
+ /**
+ * @generated
+ */
+ public static View findView(DiagramEditPart diagramEditPart, EObject targetElement, LazyElement2ViewMap lazyElement2ViewMap) {
+ boolean hasStructuralURI = false;
+ if (targetElement.eResource() instanceof XMLResource) {
+ hasStructuralURI = ((XMLResource) targetElement.eResource()).getID(targetElement) == null;
+ }
+ View view = null;
+ LinkedList<EditPart> editPartHolder = new LinkedList<EditPart>();
+ if (hasStructuralURI && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) {
+ view = lazyElement2ViewMap.getElement2ViewMap().get(targetElement);
+ } else if (findElementsInDiagramByID(diagramEditPart, targetElement, editPartHolder) > 0) {
+ EditPart editPart = editPartHolder.get(0);
+ view = editPart.getModel() instanceof View ? (View) editPart.getModel() : null;
+ }
+ return (view == null) ? diagramEditPart.getDiagramView() : view;
+ }
+
+ /**
+ * XXX This is quite suspicious code (especially editPartTmpHolder) and likely to be removed soon
+ *
+ * @generated
+ */
+ public static class LazyElement2ViewMap {
+
+ /**
+ * @generated
+ */
+ private Map<EObject, View> element2ViewMap;
+
+ /**
+ * @generated
+ */
+ private View scope;
+
+ /**
+ * @generated
+ */
+ private Set<? extends EObject> elementSet;
+
+ /**
+ * @generated
+ */
+ public LazyElement2ViewMap(View scope, Set<? extends EObject> elements) {
+ this.scope = scope;
+ this.elementSet = elements;
+ }
+
+ /**
+ * @generated
+ */
+ public final Map<EObject, View> getElement2ViewMap() {
+ if (element2ViewMap == null) {
+ element2ViewMap = new HashMap<EObject, View>();
+ // map possible notation elements to itself as these can't be found by view.getElement()
+ for (EObject element : elementSet) {
+ if (element instanceof View) {
+ View view = (View) element;
+ if (view.getDiagram() == scope.getDiagram()) {
+ element2ViewMap.put(element, view); // take only those that part of our diagram
+ }
+ }
+ }
+ buildElement2ViewMap(scope, element2ViewMap, elementSet);
+ }
+ return element2ViewMap;
+ }
+
+ /**
+ * @generated
+ */
+ private static boolean buildElement2ViewMap(View parentView, Map<EObject, View> element2ViewMap, Set<? extends EObject> elements) {
+ if (elements.size() == element2ViewMap.size()) {
+ return true;
+ }
+ if (parentView.isSetElement() && !element2ViewMap.containsKey(parentView.getElement()) && elements.contains(parentView.getElement())) {
+ element2ViewMap.put(parentView.getElement(), parentView);
+ if (elements.size() == element2ViewMap.size()) {
+ return true;
+ }
+ }
+ boolean complete = false;
+ for (Iterator<?> it = parentView.getChildren().iterator(); it.hasNext() && !complete;) {
+ complete = buildElement2ViewMap((View) it.next(), element2ViewMap, elements);
+ }
+ for (Iterator<?> it = parentView.getSourceEdges().iterator(); it.hasNext() && !complete;) {
+ complete = buildElement2ViewMap((View) it.next(), element2ViewMap, elements);
+ }
+ for (Iterator<?> it = parentView.getTargetEdges().iterator(); it.hasNext() && !complete;) {
+ complete = buildElement2ViewMap((View) it.next(), element2ViewMap, elements);
+ }
+ return complete;
+ }
+ } // LazyElement2ViewMap
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramUpdater.java
index 7bf665da6e5..5ca326610d2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramUpdater.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramUpdater.java
@@ -1,3637 +1,4192 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.tooling.runtime.update.DiagramUpdater;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ShortCutDiagramEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.uml2.uml.Association;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.DataType;
-import org.eclipse.uml2.uml.Dependency;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.ElementImport;
-import org.eclipse.uml2.uml.Enumeration;
-import org.eclipse.uml2.uml.EnumerationLiteral;
-import org.eclipse.uml2.uml.Extension;
-import org.eclipse.uml2.uml.Generalization;
-import org.eclipse.uml2.uml.Model;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PackageImport;
-import org.eclipse.uml2.uml.PackageableElement;
-import org.eclipse.uml2.uml.PrimitiveType;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.ProfileApplication;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class UMLDiagramUpdater implements DiagramUpdater {
-
- /**
- * @generated
- */
- public static final org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramUpdater INSTANCE = new UMLDiagramUpdater();
-
- /**
- * @generated
- */
- protected UMLDiagramUpdater() {
- // to prevent instantiation allowing the override
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getSemanticChildren(View view) {
- switch (UMLVisualIDRegistry.getVisualID(view)) {
- case ProfileDiagramEditPart.VISUAL_ID:
- return getProfile_1000SemanticChildren(view);
- case PackageEditPartCN.VISUAL_ID:
- return getPackage_1012SemanticChildren(view);
- case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
- return getPackagePackagedelements_1005SemanticChildren(view);
- case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
- return getPackagePackagedelements_11SemanticChildren(view);
- case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
- return getProfilePackagedelements_1042SemanticChildren(view);
- case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
- return getProfilePackagedelements_1051SemanticChildren(view);
- case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
- return getStereotypeAttributes_1071SemanticChildren(view);
- case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
- return getStereotypeAttributes_1052SemanticChildren(view);
- case StereotypeOperationCompartmentEditPart.VISUAL_ID:
- return getStereotypeOperations_1019SemanticChildren(view);
- case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
- return getStereotypeOperations_1053SemanticChildren(view);
- case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
- return getModelPackagedelements_1057SemanticChildren(view);
- case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
- return getModelPackagedelements_1058SemanticChildren(view);
- case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
- return getEnumerationLiterals_1062SemanticChildren(view);
- case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
- return getEnumerationLiterals_1063SemanticChildren(view);
- case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
- return getDataTypeAttributes_1067SemanticChildren(view);
- case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
- return getDataTypeAttributes_1069SemanticChildren(view);
- case DataTypeOperationCompartmentEditPart.VISUAL_ID:
- return getDataTypeOperations_1068SemanticChildren(view);
- case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
- return getDataTypeOperations_1070SemanticChildren(view);
- case ClassAttributeCompartmentEditPart.VISUAL_ID:
- return getClassAttributes_7017SemanticChildren(view);
- case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
- return getClassAttributes_7011SemanticChildren(view);
- case ClassOperationCompartmentEditPart.VISUAL_ID:
- return getClassOperations_7018SemanticChildren(view);
- case ClassOperationCompartmentEditPartCN.VISUAL_ID:
- return getClassOperations_7012SemanticChildren(view);
- }
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getProfile_1000SemanticChildren(View view) {
- if (!view.isSetElement()) {
- return Collections.emptyList();
- }
- Profile modelElement = (Profile) view.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getPackagedElements().iterator(); it.hasNext();) {
- PackageableElement childElement = (PackageableElement) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == DependencyNodeEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == AssociationNodeEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ClassEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == MetaclassEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ConstraintEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ModelEditPartTN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ProfileEditPartTN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PackageEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == EnumerationEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PrimitiveTypeEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == DataTypeEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getOwnedStereotypes().iterator(); it.hasNext();) {
- Stereotype childElement = (Stereotype) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == StereotypeEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getOwnedComments().iterator(); it.hasNext();) {
- Comment childElement = (Comment) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == CommentEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getPackage_1012SemanticChildren(View view) {
- if (!view.isSetElement()) {
- return Collections.emptyList();
- }
- Package modelElement = (Package) view.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getPackagedElements().iterator(); it.hasNext();) {
- PackageableElement childElement = (PackageableElement) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == PackageEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getPackagePackagedelements_1005SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Package modelElement = (Package) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedComments().iterator(); it.hasNext();) {
- Comment childElement = (Comment) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == CommentEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getPackagedElements().iterator(); it.hasNext();) {
- PackageableElement childElement = (PackageableElement) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ModelEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ProfileEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PackageEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ConstraintEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == EnumerationEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == DataTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ClassEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getOwnedStereotypes().iterator(); it.hasNext();) {
- Stereotype childElement = (Stereotype) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == StereotypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getPackagePackagedelements_11SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Package modelElement = (Package) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedComments().iterator(); it.hasNext();) {
- Comment childElement = (Comment) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == CommentEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getPackagedElements().iterator(); it.hasNext();) {
- PackageableElement childElement = (PackageableElement) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ModelEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ProfileEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PackageEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ConstraintEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == EnumerationEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == DataTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ClassEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getOwnedStereotypes().iterator(); it.hasNext();) {
- Stereotype childElement = (Stereotype) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == StereotypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getProfilePackagedelements_1042SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Profile modelElement = (Profile) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedStereotypes().iterator(); it.hasNext();) {
- Stereotype childElement = (Stereotype) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == StereotypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getPackagedElements().iterator(); it.hasNext();) {
- PackageableElement childElement = (PackageableElement) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ModelEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ProfileEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PackageEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ConstraintEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == EnumerationEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == DataTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == MetaclassEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ClassEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getOwnedComments().iterator(); it.hasNext();) {
- Comment childElement = (Comment) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == CommentEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getProfilePackagedelements_1051SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Profile modelElement = (Profile) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedStereotypes().iterator(); it.hasNext();) {
- Stereotype childElement = (Stereotype) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == StereotypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getPackagedElements().iterator(); it.hasNext();) {
- PackageableElement childElement = (PackageableElement) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ModelEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ProfileEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PackageEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ConstraintEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == EnumerationEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == DataTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == MetaclassEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ClassEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getOwnedComments().iterator(); it.hasNext();) {
- Comment childElement = (Comment) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == CommentEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getStereotypeAttributes_1071SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Stereotype modelElement = (Stereotype) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedAttributes().iterator(); it.hasNext();) {
- Property childElement = (Property) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ClassPropertyEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getStereotypeAttributes_1052SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Stereotype modelElement = (Stereotype) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedAttributes().iterator(); it.hasNext();) {
- Property childElement = (Property) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ClassPropertyEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getStereotypeOperations_1019SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Stereotype modelElement = (Stereotype) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedOperations().iterator(); it.hasNext();) {
- Operation childElement = (Operation) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ClassOperationEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getStereotypeOperations_1053SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Stereotype modelElement = (Stereotype) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedOperations().iterator(); it.hasNext();) {
- Operation childElement = (Operation) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ClassOperationEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getModelPackagedelements_1057SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Model modelElement = (Model) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedComments().iterator(); it.hasNext();) {
- Comment childElement = (Comment) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == CommentEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getPackagedElements().iterator(); it.hasNext();) {
- PackageableElement childElement = (PackageableElement) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ModelEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ProfileEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PackageEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ConstraintEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == EnumerationEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == DataTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ClassEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getModelPackagedelements_1058SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Model modelElement = (Model) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedComments().iterator(); it.hasNext();) {
- Comment childElement = (Comment) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == CommentEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- for (Iterator<?> it = modelElement.getPackagedElements().iterator(); it.hasNext();) {
- PackageableElement childElement = (PackageableElement) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ModelEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ProfileEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PackageEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ConstraintEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == EnumerationEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == DataTypeEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- if (visualID == ClassEditPartCN.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getEnumerationLiterals_1062SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Enumeration modelElement = (Enumeration) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedLiterals().iterator(); it.hasNext();) {
- EnumerationLiteral childElement = (EnumerationLiteral) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == EnumerationLiteralEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getEnumerationLiterals_1063SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Enumeration modelElement = (Enumeration) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedLiterals().iterator(); it.hasNext();) {
- EnumerationLiteral childElement = (EnumerationLiteral) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == EnumerationLiteralEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getDataTypeAttributes_1067SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- DataType modelElement = (DataType) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedAttributes().iterator(); it.hasNext();) {
- Property childElement = (Property) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == DataTypePropertyEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getDataTypeAttributes_1069SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- DataType modelElement = (DataType) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedAttributes().iterator(); it.hasNext();) {
- Property childElement = (Property) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == DataTypePropertyEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getDataTypeOperations_1068SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- DataType modelElement = (DataType) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedOperations().iterator(); it.hasNext();) {
- Operation childElement = (Operation) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == DataTypeOperationEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getDataTypeOperations_1070SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- DataType modelElement = (DataType) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedOperations().iterator(); it.hasNext();) {
- Operation childElement = (Operation) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == DataTypeOperationEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getClassAttributes_7017SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Class modelElement = (Class) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedAttributes().iterator(); it.hasNext();) {
- Property childElement = (Property) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ClassPropertyEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getClassAttributes_7011SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Class modelElement = (Class) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedAttributes().iterator(); it.hasNext();) {
- Property childElement = (Property) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ClassPropertyEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getClassOperations_7018SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Class modelElement = (Class) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedOperations().iterator(); it.hasNext();) {
- Operation childElement = (Operation) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ClassOperationEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLNodeDescriptor> getClassOperations_7012SemanticChildren(View view) {
- if (false == view.eContainer() instanceof View) {
- return Collections.emptyList();
- }
- View containerView = (View) view.eContainer();
- if (!containerView.isSetElement()) {
- return Collections.emptyList();
- }
- Class modelElement = (Class) containerView.getElement();
- LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
- for (Iterator<?> it = modelElement.getOwnedOperations().iterator(); it.hasNext();) {
- Operation childElement = (Operation) it.next();
- int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
- if (visualID == ClassOperationEditPart.VISUAL_ID) {
- result.add(new UMLNodeDescriptor(childElement, visualID));
- continue;
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getContainedLinks(View view) {
- switch (UMLVisualIDRegistry.getVisualID(view)) {
- case ProfileDiagramEditPart.VISUAL_ID:
- return getProfile_1000ContainedLinks(view);
- case DependencyNodeEditPart.VISUAL_ID:
- return getDependency_2014ContainedLinks(view);
- case AssociationNodeEditPart.VISUAL_ID:
- return getAssociation_2015ContainedLinks(view);
- case StereotypeEditPart.VISUAL_ID:
- return getStereotype_1026ContainedLinks(view);
- case ClassEditPart.VISUAL_ID:
- return getClass_2008ContainedLinks(view);
- case MetaclassEditPart.VISUAL_ID:
- return getClass_1031ContainedLinks(view);
- case CommentEditPart.VISUAL_ID:
- return getComment_1002ContainedLinks(view);
- case ConstraintEditPart.VISUAL_ID:
- return getConstraint_1014ContainedLinks(view);
- case ModelEditPartTN.VISUAL_ID:
- return getModel_2005ContainedLinks(view);
- case ProfileEditPartTN.VISUAL_ID:
- return getProfile_1030ContainedLinks(view);
- case PackageEditPart.VISUAL_ID:
- return getPackage_2007ContainedLinks(view);
- case EnumerationEditPart.VISUAL_ID:
- return getEnumeration_2006ContainedLinks(view);
- case PrimitiveTypeEditPart.VISUAL_ID:
- return getPrimitiveType_2009ContainedLinks(view);
- case DataTypeEditPart.VISUAL_ID:
- return getDataType_2010ContainedLinks(view);
- case ShortCutDiagramEditPart.VISUAL_ID:
- return getDiagram_2016ContainedLinks(view);
- case PrimitiveTypeEditPartCN.VISUAL_ID:
- return getPrimitiveType_3026ContainedLinks(view);
- case DataTypeOperationEditPart.VISUAL_ID:
- return getOperation_3019ContainedLinks(view);
- case EnumerationLiteralEditPart.VISUAL_ID:
- return getEnumerationLiteral_1037ContainedLinks(view);
- case DataTypePropertyEditPart.VISUAL_ID:
- return getProperty_3018ContainedLinks(view);
- case ClassPropertyEditPart.VISUAL_ID:
- return getProperty_3002ContainedLinks(view);
- case ClassOperationEditPart.VISUAL_ID:
- return getOperation_3020ContainedLinks(view);
- case StereotypeEditPartCN.VISUAL_ID:
- return getStereotype_1023ContainedLinks(view);
- case ClassEditPartCN.VISUAL_ID:
- return getClass_3010ContainedLinks(view);
- case MetaclassEditPartCN.VISUAL_ID:
- return getClass_3028ContainedLinks(view);
- case CommentEditPartCN.VISUAL_ID:
- return getComment_1007ContainedLinks(view);
- case ModelEditPartCN.VISUAL_ID:
- return getModel_1027ContainedLinks(view);
- case ProfileEditPartCN.VISUAL_ID:
- return getProfile_1024ContainedLinks(view);
- case PackageEditPartCN.VISUAL_ID:
- return getPackage_1012ContainedLinks(view);
- case ConstraintEditPartCN.VISUAL_ID:
- return getConstraint_1028ContainedLinks(view);
- case EnumerationEditPartCN.VISUAL_ID:
- return getEnumeration_3025ContainedLinks(view);
- case DataTypeEditPartCN.VISUAL_ID:
- return getDataType_3027ContainedLinks(view);
- case ExtensionEditPart.VISUAL_ID:
- return getExtension_1013ContainedLinks(view);
- case AssociationEditPart.VISUAL_ID:
- return getAssociation_4001ContainedLinks(view);
- case ProfileApplicationEditPart.VISUAL_ID:
- return getProfileApplication_1045ContainedLinks(view);
- case AssociationBranchEditPart.VISUAL_ID:
- return getAssociation_4019ContainedLinks(view);
- case GeneralizationEditPart.VISUAL_ID:
- return getGeneralization_4002ContainedLinks(view);
- case DependencyEditPart.VISUAL_ID:
- return getDependency_4008ContainedLinks(view);
- case DependencyBranchEditPart.VISUAL_ID:
- return getDependency_4018ContainedLinks(view);
- case ElementImportEditPart.VISUAL_ID:
- return getElementImport_1064ContainedLinks(view);
- case PackageImportEditPart.VISUAL_ID:
- return getPackageImport_1065ContainedLinks(view);
- }
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getIncomingLinks(View view) {
- switch (UMLVisualIDRegistry.getVisualID(view)) {
- case DependencyNodeEditPart.VISUAL_ID:
- return getDependency_2014IncomingLinks(view);
- case AssociationNodeEditPart.VISUAL_ID:
- return getAssociation_2015IncomingLinks(view);
- case StereotypeEditPart.VISUAL_ID:
- return getStereotype_1026IncomingLinks(view);
- case ClassEditPart.VISUAL_ID:
- return getClass_2008IncomingLinks(view);
- case MetaclassEditPart.VISUAL_ID:
- return getClass_1031IncomingLinks(view);
- case CommentEditPart.VISUAL_ID:
- return getComment_1002IncomingLinks(view);
- case ConstraintEditPart.VISUAL_ID:
- return getConstraint_1014IncomingLinks(view);
- case ModelEditPartTN.VISUAL_ID:
- return getModel_2005IncomingLinks(view);
- case ProfileEditPartTN.VISUAL_ID:
- return getProfile_1030IncomingLinks(view);
- case PackageEditPart.VISUAL_ID:
- return getPackage_2007IncomingLinks(view);
- case EnumerationEditPart.VISUAL_ID:
- return getEnumeration_2006IncomingLinks(view);
- case PrimitiveTypeEditPart.VISUAL_ID:
- return getPrimitiveType_2009IncomingLinks(view);
- case DataTypeEditPart.VISUAL_ID:
- return getDataType_2010IncomingLinks(view);
- case ShortCutDiagramEditPart.VISUAL_ID:
- return getDiagram_2016IncomingLinks(view);
- case PrimitiveTypeEditPartCN.VISUAL_ID:
- return getPrimitiveType_3026IncomingLinks(view);
- case DataTypeOperationEditPart.VISUAL_ID:
- return getOperation_3019IncomingLinks(view);
- case EnumerationLiteralEditPart.VISUAL_ID:
- return getEnumerationLiteral_1037IncomingLinks(view);
- case DataTypePropertyEditPart.VISUAL_ID:
- return getProperty_3018IncomingLinks(view);
- case ClassPropertyEditPart.VISUAL_ID:
- return getProperty_3002IncomingLinks(view);
- case ClassOperationEditPart.VISUAL_ID:
- return getOperation_3020IncomingLinks(view);
- case StereotypeEditPartCN.VISUAL_ID:
- return getStereotype_1023IncomingLinks(view);
- case ClassEditPartCN.VISUAL_ID:
- return getClass_3010IncomingLinks(view);
- case MetaclassEditPartCN.VISUAL_ID:
- return getClass_3028IncomingLinks(view);
- case CommentEditPartCN.VISUAL_ID:
- return getComment_1007IncomingLinks(view);
- case ModelEditPartCN.VISUAL_ID:
- return getModel_1027IncomingLinks(view);
- case ProfileEditPartCN.VISUAL_ID:
- return getProfile_1024IncomingLinks(view);
- case PackageEditPartCN.VISUAL_ID:
- return getPackage_1012IncomingLinks(view);
- case ConstraintEditPartCN.VISUAL_ID:
- return getConstraint_1028IncomingLinks(view);
- case EnumerationEditPartCN.VISUAL_ID:
- return getEnumeration_3025IncomingLinks(view);
- case DataTypeEditPartCN.VISUAL_ID:
- return getDataType_3027IncomingLinks(view);
- case ExtensionEditPart.VISUAL_ID:
- return getExtension_1013IncomingLinks(view);
- case AssociationEditPart.VISUAL_ID:
- return getAssociation_4001IncomingLinks(view);
- case ProfileApplicationEditPart.VISUAL_ID:
- return getProfileApplication_1045IncomingLinks(view);
- case AssociationBranchEditPart.VISUAL_ID:
- return getAssociation_4019IncomingLinks(view);
- case GeneralizationEditPart.VISUAL_ID:
- return getGeneralization_4002IncomingLinks(view);
- case DependencyEditPart.VISUAL_ID:
- return getDependency_4008IncomingLinks(view);
- case DependencyBranchEditPart.VISUAL_ID:
- return getDependency_4018IncomingLinks(view);
- case ElementImportEditPart.VISUAL_ID:
- return getElementImport_1064IncomingLinks(view);
- case PackageImportEditPart.VISUAL_ID:
- return getPackageImport_1065IncomingLinks(view);
- }
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getOutgoingLinks(View view) {
- switch (UMLVisualIDRegistry.getVisualID(view)) {
- case DependencyNodeEditPart.VISUAL_ID:
- return getDependency_2014OutgoingLinks(view);
- case AssociationNodeEditPart.VISUAL_ID:
- return getAssociation_2015OutgoingLinks(view);
- case StereotypeEditPart.VISUAL_ID:
- return getStereotype_1026OutgoingLinks(view);
- case ClassEditPart.VISUAL_ID:
- return getClass_2008OutgoingLinks(view);
- case MetaclassEditPart.VISUAL_ID:
- return getClass_1031OutgoingLinks(view);
- case CommentEditPart.VISUAL_ID:
- return getComment_1002OutgoingLinks(view);
- case ConstraintEditPart.VISUAL_ID:
- return getConstraint_1014OutgoingLinks(view);
- case ModelEditPartTN.VISUAL_ID:
- return getModel_2005OutgoingLinks(view);
- case ProfileEditPartTN.VISUAL_ID:
- return getProfile_1030OutgoingLinks(view);
- case PackageEditPart.VISUAL_ID:
- return getPackage_2007OutgoingLinks(view);
- case EnumerationEditPart.VISUAL_ID:
- return getEnumeration_2006OutgoingLinks(view);
- case PrimitiveTypeEditPart.VISUAL_ID:
- return getPrimitiveType_2009OutgoingLinks(view);
- case DataTypeEditPart.VISUAL_ID:
- return getDataType_2010OutgoingLinks(view);
- case ShortCutDiagramEditPart.VISUAL_ID:
- return getDiagram_2016OutgoingLinks(view);
- case PrimitiveTypeEditPartCN.VISUAL_ID:
- return getPrimitiveType_3026OutgoingLinks(view);
- case DataTypeOperationEditPart.VISUAL_ID:
- return getOperation_3019OutgoingLinks(view);
- case EnumerationLiteralEditPart.VISUAL_ID:
- return getEnumerationLiteral_1037OutgoingLinks(view);
- case DataTypePropertyEditPart.VISUAL_ID:
- return getProperty_3018OutgoingLinks(view);
- case ClassPropertyEditPart.VISUAL_ID:
- return getProperty_3002OutgoingLinks(view);
- case ClassOperationEditPart.VISUAL_ID:
- return getOperation_3020OutgoingLinks(view);
- case StereotypeEditPartCN.VISUAL_ID:
- return getStereotype_1023OutgoingLinks(view);
- case ClassEditPartCN.VISUAL_ID:
- return getClass_3010OutgoingLinks(view);
- case MetaclassEditPartCN.VISUAL_ID:
- return getClass_3028OutgoingLinks(view);
- case CommentEditPartCN.VISUAL_ID:
- return getComment_1007OutgoingLinks(view);
- case ModelEditPartCN.VISUAL_ID:
- return getModel_1027OutgoingLinks(view);
- case ProfileEditPartCN.VISUAL_ID:
- return getProfile_1024OutgoingLinks(view);
- case PackageEditPartCN.VISUAL_ID:
- return getPackage_1012OutgoingLinks(view);
- case ConstraintEditPartCN.VISUAL_ID:
- return getConstraint_1028OutgoingLinks(view);
- case EnumerationEditPartCN.VISUAL_ID:
- return getEnumeration_3025OutgoingLinks(view);
- case DataTypeEditPartCN.VISUAL_ID:
- return getDataType_3027OutgoingLinks(view);
- case ExtensionEditPart.VISUAL_ID:
- return getExtension_1013OutgoingLinks(view);
- case AssociationEditPart.VISUAL_ID:
- return getAssociation_4001OutgoingLinks(view);
- case ProfileApplicationEditPart.VISUAL_ID:
- return getProfileApplication_1045OutgoingLinks(view);
- case AssociationBranchEditPart.VISUAL_ID:
- return getAssociation_4019OutgoingLinks(view);
- case GeneralizationEditPart.VISUAL_ID:
- return getGeneralization_4002OutgoingLinks(view);
- case DependencyEditPart.VISUAL_ID:
- return getDependency_4008OutgoingLinks(view);
- case DependencyBranchEditPart.VISUAL_ID:
- return getDependency_4018OutgoingLinks(view);
- case ElementImportEditPart.VISUAL_ID:
- return getElementImport_1064OutgoingLinks(view);
- case PackageImportEditPart.VISUAL_ID:
- return getPackageImport_1065OutgoingLinks(view);
- }
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProfile_1000ContainedLinks(View view) {
- Profile modelElement = (Profile) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Extension_1013(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDependency_2014ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getAssociation_2015ContainedLinks(View view) {
- Association modelElement = (Association) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getStereotype_1026ContainedLinks(View view) {
- Stereotype modelElement = (Stereotype) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_2008ContainedLinks(View view) {
- Class modelElement = (Class) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_1031ContainedLinks(View view) {
- Class modelElement = (Class) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getComment_1002ContainedLinks(View view) {
- Comment modelElement = (Comment) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getConstraint_1014ContainedLinks(View view) {
- Constraint modelElement = (Constraint) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement));
- result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_Context_8500(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getModel_2005ContainedLinks(View view) {
- Model modelElement = (Model) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Extension_1013(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProfile_1030ContainedLinks(View view) {
- Profile modelElement = (Profile) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Extension_1013(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPackage_2007ContainedLinks(View view) {
- Package modelElement = (Package) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Extension_1013(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getEnumeration_2006ContainedLinks(View view) {
- Enumeration modelElement = (Enumeration) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPrimitiveType_2009ContainedLinks(View view) {
- PrimitiveType modelElement = (PrimitiveType) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDataType_2010ContainedLinks(View view) {
- DataType modelElement = (DataType) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDiagram_2016ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPrimitiveType_3026ContainedLinks(View view) {
- PrimitiveType modelElement = (PrimitiveType) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getOperation_3019ContainedLinks(View view) {
- Operation modelElement = (Operation) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getEnumerationLiteral_1037ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProperty_3018ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProperty_3002ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getOperation_3020ContainedLinks(View view) {
- Operation modelElement = (Operation) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getStereotype_1023ContainedLinks(View view) {
- Stereotype modelElement = (Stereotype) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_3010ContainedLinks(View view) {
- Class modelElement = (Class) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_3028ContainedLinks(View view) {
- Class modelElement = (Class) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getComment_1007ContainedLinks(View view) {
- Comment modelElement = (Comment) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getModel_1027ContainedLinks(View view) {
- Model modelElement = (Model) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Extension_1013(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProfile_1024ContainedLinks(View view) {
- Profile modelElement = (Profile) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Extension_1013(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPackage_1012ContainedLinks(View view) {
- Package modelElement = (Package) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Extension_1013(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getConstraint_1028ContainedLinks(View view) {
- Constraint modelElement = (Constraint) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement));
- result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_Context_8500(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getEnumeration_3025ContainedLinks(View view) {
- Enumeration modelElement = (Enumeration) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDataType_3027ContainedLinks(View view) {
- DataType modelElement = (DataType) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getExtension_1013ContainedLinks(View view) {
- Extension modelElement = (Extension) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getAssociation_4001ContainedLinks(View view) {
- Association modelElement = (Association) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProfileApplication_1045ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getAssociation_4019ContainedLinks(View view) {
- Association modelElement = (Association) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getGeneralization_4002ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDependency_4008ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDependency_4018ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getElementImport_1064ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPackageImport_1065ContainedLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDependency_2014IncomingLinks(View view) {
- Dependency modelElement = (Dependency) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getAssociation_2015IncomingLinks(View view) {
- Association modelElement = (Association) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getStereotype_1026IncomingLinks(View view) {
- Stereotype modelElement = (Stereotype) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Extension_1013(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_2008IncomingLinks(View view) {
- Class modelElement = (Class) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Extension_1013(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_1031IncomingLinks(View view) {
- Class modelElement = (Class) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Extension_1013(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getComment_1002IncomingLinks(View view) {
- Comment modelElement = (Comment) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getConstraint_1014IncomingLinks(View view) {
- Constraint modelElement = (Constraint) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getModel_2005IncomingLinks(View view) {
- Model modelElement = (Model) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProfile_1030IncomingLinks(View view) {
- Profile modelElement = (Profile) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_ProfileApplication_1045(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPackage_2007IncomingLinks(View view) {
- Package modelElement = (Package) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getEnumeration_2006IncomingLinks(View view) {
- Enumeration modelElement = (Enumeration) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPrimitiveType_2009IncomingLinks(View view) {
- PrimitiveType modelElement = (PrimitiveType) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDataType_2010IncomingLinks(View view) {
- DataType modelElement = (DataType) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDiagram_2016IncomingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPrimitiveType_3026IncomingLinks(View view) {
- PrimitiveType modelElement = (PrimitiveType) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getOperation_3019IncomingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getEnumerationLiteral_1037IncomingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProperty_3018IncomingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProperty_3002IncomingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getOperation_3020IncomingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getStereotype_1023IncomingLinks(View view) {
- Stereotype modelElement = (Stereotype) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Extension_1013(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_3010IncomingLinks(View view) {
- Class modelElement = (Class) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Extension_1013(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_3028IncomingLinks(View view) {
- Class modelElement = (Class) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Extension_1013(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getComment_1007IncomingLinks(View view) {
- Comment modelElement = (Comment) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getModel_1027IncomingLinks(View view) {
- Model modelElement = (Model) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProfile_1024IncomingLinks(View view) {
- Profile modelElement = (Profile) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_ProfileApplication_1045(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPackage_1012IncomingLinks(View view) {
- Package modelElement = (Package) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getConstraint_1028IncomingLinks(View view) {
- Constraint modelElement = (Constraint) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getEnumeration_3025IncomingLinks(View view) {
- Enumeration modelElement = (Enumeration) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDataType_3027IncomingLinks(View view) {
- DataType modelElement = (DataType) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getExtension_1013IncomingLinks(View view) {
- Extension modelElement = (Extension) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getAssociation_4001IncomingLinks(View view) {
- Association modelElement = (Association) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProfileApplication_1045IncomingLinks(View view) {
- ProfileApplication modelElement = (ProfileApplication) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getAssociation_4019IncomingLinks(View view) {
- Association modelElement = (Association) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Association_4001(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Association_4019(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getGeneralization_4002IncomingLinks(View view) {
- Generalization modelElement = (Generalization) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDependency_4008IncomingLinks(View view) {
- Dependency modelElement = (Dependency) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDependency_4018IncomingLinks(View view) {
- Dependency modelElement = (Dependency) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018(modelElement, crossReferencer));
- result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getElementImport_1064IncomingLinks(View view) {
- ElementImport modelElement = (ElementImport) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPackageImport_1065IncomingLinks(View view) {
- PackageImport modelElement = (PackageImport) view.getElement();
- CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement, crossReferencer));
- result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement, crossReferencer));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDependency_2014OutgoingLinks(View view) {
- Dependency modelElement = (Dependency) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getAssociation_2015OutgoingLinks(View view) {
- Association modelElement = (Association) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getStereotype_1026OutgoingLinks(View view) {
- Stereotype modelElement = (Stereotype) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_2008OutgoingLinks(View view) {
- Class modelElement = (Class) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_1031OutgoingLinks(View view) {
- Class modelElement = (Class) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getComment_1002OutgoingLinks(View view) {
- Comment modelElement = (Comment) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getConstraint_1014OutgoingLinks(View view) {
- Constraint modelElement = (Constraint) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement));
- result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_Context_8500(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getModel_2005OutgoingLinks(View view) {
- Model modelElement = (Model) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProfile_1030OutgoingLinks(View view) {
- Profile modelElement = (Profile) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPackage_2007OutgoingLinks(View view) {
- Package modelElement = (Package) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getEnumeration_2006OutgoingLinks(View view) {
- Enumeration modelElement = (Enumeration) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPrimitiveType_2009OutgoingLinks(View view) {
- PrimitiveType modelElement = (PrimitiveType) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDataType_2010OutgoingLinks(View view) {
- DataType modelElement = (DataType) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDiagram_2016OutgoingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPrimitiveType_3026OutgoingLinks(View view) {
- PrimitiveType modelElement = (PrimitiveType) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getOperation_3019OutgoingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getEnumerationLiteral_1037OutgoingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProperty_3018OutgoingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProperty_3002OutgoingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getOperation_3020OutgoingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getStereotype_1023OutgoingLinks(View view) {
- Stereotype modelElement = (Stereotype) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_3010OutgoingLinks(View view) {
- Class modelElement = (Class) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getClass_3028OutgoingLinks(View view) {
- Class modelElement = (Class) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getComment_1007OutgoingLinks(View view) {
- Comment modelElement = (Comment) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getModel_1027OutgoingLinks(View view) {
- Model modelElement = (Model) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProfile_1024OutgoingLinks(View view) {
- Profile modelElement = (Profile) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPackage_1012OutgoingLinks(View view) {
- Package modelElement = (Package) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getConstraint_1028OutgoingLinks(View view) {
- Constraint modelElement = (Constraint) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(modelElement));
- result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_Context_8500(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getEnumeration_3025OutgoingLinks(View view) {
- Enumeration modelElement = (Enumeration) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDataType_3027OutgoingLinks(View view) {
- DataType modelElement = (DataType) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getExtension_1013OutgoingLinks(View view) {
- Extension modelElement = (Extension) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getAssociation_4001OutgoingLinks(View view) {
- Association modelElement = (Association) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getProfileApplication_1045OutgoingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getAssociation_4019OutgoingLinks(View view) {
- Association modelElement = (Association) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4001(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Association_4019(modelElement));
- result.addAll(getContainedTypeModelFacetLinks_Generalization_4002(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getGeneralization_4002OutgoingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDependency_4008OutgoingLinks(View view) {
- Dependency modelElement = (Dependency) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getDependency_4018OutgoingLinks(View view) {
- Dependency modelElement = (Dependency) view.getElement();
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008(modelElement));
- result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018(modelElement));
- return result;
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getElementImport_1064OutgoingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- public List<UMLLinkDescriptor> getPackageImport_1065OutgoingLinks(View view) {
- return Collections.emptyList();
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Extension_1013(Package container) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof Extension) {
- continue;
- }
- Extension link = (Extension) linkObject;
- if (ExtensionEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- Class dst = link.getMetaclass();
- List<?> sources = link.getOwnedEnds();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof Property) {
- continue;
- }
- Property src = (Property) theSource;
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Extension_1013, ExtensionEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Association_4001(Package container) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof Association) {
- continue;
- }
- Association link = (Association) linkObject;
- if (AssociationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> targets = link.getEndTypes();
- Object theTarget = targets.size() == 1 ? targets.get(0) : null;
- if (false == theTarget instanceof Type) {
- continue;
- }
- Type dst = (Type) theTarget;
- List<?> sources = link.getEndTypes();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof Type) {
- continue;
- }
- Type src = (Type) theSource;
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Association_4001, AssociationEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_ProfileApplication_1045(Package container) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getProfileApplications().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof ProfileApplication) {
- continue;
- }
- ProfileApplication link = (ProfileApplication) linkObject;
- if (ProfileApplicationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- Profile dst = link.getAppliedProfile();
- Package src = link.getApplyingPackage();
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.ProfileApplication_1045, ProfileApplicationEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Association_4019(Package container) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof Association) {
- continue;
- }
- Association link = (Association) linkObject;
- if (AssociationBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> targets = link.getEndTypes();
- Object theTarget = targets.size() == 1 ? targets.get(0) : null;
- if (false == theTarget instanceof Type) {
- continue;
- }
- Type dst = (Type) theTarget;
- List<?> sources = link.getEndTypes();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof Type) {
- continue;
- }
- Type src = (Type) theSource;
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Association_4019, AssociationBranchEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Generalization_4002(Classifier container) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getGeneralizations().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof Generalization) {
- continue;
- }
- Generalization link = (Generalization) linkObject;
- if (GeneralizationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- Classifier dst = link.getGeneral();
- result.add(new UMLLinkDescriptor(container, dst, link, UMLElementTypes.Generalization_4002, GeneralizationEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Dependency_4008(Package container) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof Dependency) {
- continue;
- }
- Dependency link = (Dependency) linkObject;
- if (DependencyEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> targets = link.getSuppliers();
- Object theTarget = targets.size() == 1 ? targets.get(0) : null;
- if (false == theTarget instanceof NamedElement) {
- continue;
- }
- NamedElement dst = (NamedElement) theTarget;
- List<?> sources = link.getClients();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof NamedElement) {
- continue;
- }
- NamedElement src = (NamedElement) theSource;
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Dependency_4008, DependencyEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Dependency_4018(Package container) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof Dependency) {
- continue;
- }
- Dependency link = (Dependency) linkObject;
- if (DependencyBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> targets = link.getSuppliers();
- Object theTarget = targets.size() == 1 ? targets.get(0) : null;
- if (false == theTarget instanceof NamedElement) {
- continue;
- }
- NamedElement dst = (NamedElement) theTarget;
- List<?> sources = link.getClients();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof NamedElement) {
- continue;
- }
- NamedElement src = (NamedElement) theSource;
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Dependency_4018, DependencyBranchEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_ElementImport_1064(Namespace container) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getElementImports().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof ElementImport) {
- continue;
- }
- ElementImport link = (ElementImport) linkObject;
- if (ElementImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- PackageableElement dst = link.getImportedElement();
- Namespace src = link.getImportingNamespace();
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.ElementImport_1064, ElementImportEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_PackageImport_1065(Namespace container) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackageImports().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof PackageImport) {
- continue;
- }
- PackageImport link = (PackageImport) linkObject;
- if (PackageImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- Package dst = link.getImportedPackage();
- Namespace src = link.getImportingNamespace();
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.PackageImport_1065, PackageImportEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Extension_1013(Class target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getExtension_Metaclass() || false == setting.getEObject() instanceof Extension) {
- continue;
- }
- Extension link = (Extension) setting.getEObject();
- if (ExtensionEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> sources = link.getOwnedEnds();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof Property) {
- continue;
- }
- Property src = (Property) theSource;
- result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Extension_1013, ExtensionEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Association_4001(Type target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getAssociation_EndType() || false == setting.getEObject() instanceof Association) {
- continue;
- }
- Association link = (Association) setting.getEObject();
- if (AssociationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> sources = link.getEndTypes();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof Type) {
- continue;
- }
- Type src = (Type) theSource;
- result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Association_4001, AssociationEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_ProfileApplication_1045(Profile target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getProfileApplication_AppliedProfile() || false == setting.getEObject() instanceof ProfileApplication) {
- continue;
- }
- ProfileApplication link = (ProfileApplication) setting.getEObject();
- if (ProfileApplicationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- Package src = link.getApplyingPackage();
- result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.ProfileApplication_1045, ProfileApplicationEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Association_4019(Type target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getAssociation_EndType() || false == setting.getEObject() instanceof Association) {
- continue;
- }
- Association link = (Association) setting.getEObject();
- if (AssociationBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> sources = link.getEndTypes();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof Type) {
- continue;
- }
- Type src = (Type) theSource;
- result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Association_4019, AssociationBranchEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Generalization_4002(Classifier target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getGeneralization_General() || false == setting.getEObject() instanceof Generalization) {
- continue;
- }
- Generalization link = (Generalization) setting.getEObject();
- if (GeneralizationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- if (false == link.eContainer() instanceof Classifier) {
- continue;
- }
- Classifier container = (Classifier) link.eContainer();
- result.add(new UMLLinkDescriptor(container, target, link, UMLElementTypes.Generalization_4002, GeneralizationEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Dependency_4008(NamedElement target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getDependency_Supplier() || false == setting.getEObject() instanceof Dependency) {
- continue;
- }
- Dependency link = (Dependency) setting.getEObject();
- if (DependencyEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> sources = link.getClients();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof NamedElement) {
- continue;
- }
- NamedElement src = (NamedElement) theSource;
- result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Dependency_4008, DependencyEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Dependency_4018(NamedElement target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getDependency_Supplier() || false == setting.getEObject() instanceof Dependency) {
- continue;
- }
- Dependency link = (Dependency) setting.getEObject();
- if (DependencyBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> sources = link.getClients();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof NamedElement) {
- continue;
- }
- NamedElement src = (NamedElement) theSource;
- result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Dependency_4018, DependencyBranchEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_ElementImport_1064(PackageableElement target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getElementImport_ImportedElement() || false == setting.getEObject() instanceof ElementImport) {
- continue;
- }
- ElementImport link = (ElementImport) setting.getEObject();
- if (ElementImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- Namespace src = link.getImportingNamespace();
- result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.ElementImport_1064, ElementImportEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_PackageImport_1065(Package target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getPackageImport_ImportedPackage() || false == setting.getEObject() instanceof PackageImport) {
- continue;
- }
- PackageImport link = (PackageImport) setting.getEObject();
- if (PackageImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- Namespace src = link.getImportingNamespace();
- result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.PackageImport_1065, PackageImportEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(Element target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getComment_AnnotatedElement()) {
- result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.CommentAnnotatedElement_1022, CommentAnnotatedElementEditPart.VISUAL_ID));
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(Element target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getConstraint_ConstrainedElement()) {
- result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.ConstraintConstrainedElement_4014, ConstraintConstrainedElementEditPart.VISUAL_ID));
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Constraint_Context_8500(Namespace target, CrossReferenceAdapter crossReferencer) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
- for (EStructuralFeature.Setting setting : settings) {
- if (setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getConstraint_Context()) {
- result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.ConstraintContext_8500, ContextLinkEditPart.VISUAL_ID));
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_Association_4001(Type source) {
- Package container = null;
- // Find container element for the 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 && container == null; element = element.eContainer()) {
- if (element instanceof Package) {
- container = (Package) element;
- }
- }
- if (container == null) {
- return Collections.emptyList();
- }
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof Association) {
- continue;
- }
- Association link = (Association) linkObject;
- if (AssociationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> targets = link.getEndTypes();
- Object theTarget = targets.size() == 1 ? targets.get(0) : null;
- if (false == theTarget instanceof Type) {
- continue;
- }
- Type dst = (Type) theTarget;
- List<?> sources = link.getEndTypes();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof Type) {
- continue;
- }
- Type src = (Type) theSource;
- if (src != source) {
- continue;
- }
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Association_4001, AssociationEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_ProfileApplication_1045(Package source) {
- Package container = null;
- // Find container element for the 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 && container == null; element = element.eContainer()) {
- if (element instanceof Package) {
- container = (Package) element;
- }
- }
- if (container == null) {
- return Collections.emptyList();
- }
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getProfileApplications().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof ProfileApplication) {
- continue;
- }
- ProfileApplication link = (ProfileApplication) linkObject;
- if (ProfileApplicationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- Profile dst = link.getAppliedProfile();
- Package src = link.getApplyingPackage();
- if (src != source) {
- continue;
- }
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.ProfileApplication_1045, ProfileApplicationEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_Association_4019(Type source) {
- Package container = null;
- // Find container element for the 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 && container == null; element = element.eContainer()) {
- if (element instanceof Package) {
- container = (Package) element;
- }
- }
- if (container == null) {
- return Collections.emptyList();
- }
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof Association) {
- continue;
- }
- Association link = (Association) linkObject;
- if (AssociationBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> targets = link.getEndTypes();
- Object theTarget = targets.size() == 1 ? targets.get(0) : null;
- if (false == theTarget instanceof Type) {
- continue;
- }
- Type dst = (Type) theTarget;
- List<?> sources = link.getEndTypes();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof Type) {
- continue;
- }
- Type src = (Type) theSource;
- if (src != source) {
- continue;
- }
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Association_4019, AssociationBranchEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_Dependency_4008(NamedElement source) {
- Package container = null;
- // Find container element for the 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 && container == null; element = element.eContainer()) {
- if (element instanceof Package) {
- container = (Package) element;
- }
- }
- if (container == null) {
- return Collections.emptyList();
- }
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof Dependency) {
- continue;
- }
- Dependency link = (Dependency) linkObject;
- if (DependencyEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> targets = link.getSuppliers();
- Object theTarget = targets.size() == 1 ? targets.get(0) : null;
- if (false == theTarget instanceof NamedElement) {
- continue;
- }
- NamedElement dst = (NamedElement) theTarget;
- List<?> sources = link.getClients();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof NamedElement) {
- continue;
- }
- NamedElement src = (NamedElement) theSource;
- if (src != source) {
- continue;
- }
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Dependency_4008, DependencyEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_Dependency_4018(NamedElement source) {
- Package container = null;
- // Find container element for the 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 && container == null; element = element.eContainer()) {
- if (element instanceof Package) {
- container = (Package) element;
- }
- }
- if (container == null) {
- return Collections.emptyList();
- }
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof Dependency) {
- continue;
- }
- Dependency link = (Dependency) linkObject;
- if (DependencyBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- List<?> targets = link.getSuppliers();
- Object theTarget = targets.size() == 1 ? targets.get(0) : null;
- if (false == theTarget instanceof NamedElement) {
- continue;
- }
- NamedElement dst = (NamedElement) theTarget;
- List<?> sources = link.getClients();
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if (false == theSource instanceof NamedElement) {
- continue;
- }
- NamedElement src = (NamedElement) theSource;
- if (src != source) {
- continue;
- }
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Dependency_4018, DependencyBranchEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_ElementImport_1064(Namespace source) {
- Namespace container = null;
- // Find container element for the 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 && container == null; element = element.eContainer()) {
- if (element instanceof Namespace) {
- container = (Namespace) element;
- }
- }
- if (container == null) {
- return Collections.emptyList();
- }
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getElementImports().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof ElementImport) {
- continue;
- }
- ElementImport link = (ElementImport) linkObject;
- if (ElementImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- PackageableElement dst = link.getImportedElement();
- Namespace src = link.getImportingNamespace();
- if (src != source) {
- continue;
- }
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.ElementImport_1064, ElementImportEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_PackageImport_1065(Namespace source) {
- Namespace container = null;
- // Find container element for the 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 && container == null; element = element.eContainer()) {
- if (element instanceof Namespace) {
- container = (Namespace) element;
- }
- }
- if (container == null) {
- return Collections.emptyList();
- }
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> links = container.getPackageImports().iterator(); links.hasNext();) {
- EObject linkObject = (EObject) links.next();
- if (false == linkObject instanceof PackageImport) {
- continue;
- }
- PackageImport link = (PackageImport) linkObject;
- if (PackageImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
- continue;
- }
- Package dst = link.getImportedPackage();
- Namespace src = link.getImportingNamespace();
- if (src != source) {
- continue;
- }
- result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.PackageImport_1065, PackageImportEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(Comment source) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> destinations = source.getAnnotatedElements().iterator(); destinations.hasNext();) {
- Element destination = (Element) destinations.next();
- result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.CommentAnnotatedElement_1022, CommentAnnotatedElementEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(Constraint source) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- for (Iterator<?> destinations = source.getConstrainedElements().iterator(); destinations.hasNext();) {
- Element destination = (Element) destinations.next();
- result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.ConstraintConstrainedElement_4014, ConstraintConstrainedElementEditPart.VISUAL_ID));
- }
- return result;
- }
-
- /**
- * @generated
- */
- protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Constraint_Context_8500(Constraint source) {
- LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
- Namespace destination = source.getContext();
- if (destination == null) {
- return result;
- }
- result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.ConstraintContext_8500, ContextLinkEditPart.VISUAL_ID));
- return result;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.update.DiagramUpdater;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassAttributeCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeAttributeCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEnumerationLiteralCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelPackageableElementCompartmentEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackagePackageableElementCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfilePackageableElementCompartmentEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ShortCutDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeAttributeCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeOperationCompartmentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.ElementImport;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageImport;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.ProfileApplication;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class UMLDiagramUpdater implements DiagramUpdater {
+
+ /**
+ * @generated
+ */
+ public static final org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramUpdater INSTANCE = new UMLDiagramUpdater();
+
+ /**
+ * @generated
+ */
+ protected UMLDiagramUpdater() {
+ //to prevent instantiation allowing the override
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getSemanticChildren(View view) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case ProfileDiagramEditPart.VISUAL_ID:
+ return getProfile_1000SemanticChildren(view);
+ case PackageEditPartCN.VISUAL_ID:
+ return getPackage_1012SemanticChildren(view);
+ case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
+ return getPackagePackagedelements_1005SemanticChildren(view);
+ case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ return getPackagePackagedelements_11SemanticChildren(view);
+ case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
+ return getProfilePackagedelements_1042SemanticChildren(view);
+ case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ return getProfilePackagedelements_1051SemanticChildren(view);
+ case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
+ return getStereotypeAttributes_1071SemanticChildren(view);
+ case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ return getStereotypeAttributes_1052SemanticChildren(view);
+ case StereotypeOperationCompartmentEditPart.VISUAL_ID:
+ return getStereotypeOperations_1019SemanticChildren(view);
+ case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
+ return getStereotypeOperations_1053SemanticChildren(view);
+ case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
+ return getModelPackagedelements_1057SemanticChildren(view);
+ case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
+ return getModelPackagedelements_1058SemanticChildren(view);
+ case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
+ return getEnumerationLiterals_1062SemanticChildren(view);
+ case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
+ return getEnumerationLiterals_1063SemanticChildren(view);
+ case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
+ return getDataTypeAttributes_1067SemanticChildren(view);
+ case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ return getDataTypeAttributes_1069SemanticChildren(view);
+ case DataTypeOperationCompartmentEditPart.VISUAL_ID:
+ return getDataTypeOperations_1068SemanticChildren(view);
+ case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
+ return getDataTypeOperations_1070SemanticChildren(view);
+ case ClassAttributeCompartmentEditPart.VISUAL_ID:
+ return getClassAttributes_7017SemanticChildren(view);
+ case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
+ return getClassAttributes_7011SemanticChildren(view);
+ case ClassOperationCompartmentEditPart.VISUAL_ID:
+ return getClassOperations_7018SemanticChildren(view);
+ case ClassOperationCompartmentEditPartCN.VISUAL_ID:
+ return getClassOperations_7012SemanticChildren(view);
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getProfile_1000SemanticChildren(View view) {
+ if (!view.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Profile modelElement = (Profile) view.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getPackagedElements()
+ .iterator(); it.hasNext();) {
+ PackageableElement childElement = (PackageableElement) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == DependencyNodeEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == AssociationNodeEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ClassEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == MetaclassEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ConstraintEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ModelEditPartTN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ProfileEditPartTN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PackageEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == EnumerationEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PrimitiveTypeEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == DataTypeEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getOwnedStereotypes()
+ .iterator(); it.hasNext();) {
+ Stereotype childElement = (Stereotype) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == StereotypeEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getOwnedComments()
+ .iterator(); it.hasNext();) {
+ Comment childElement = (Comment) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == CommentEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getPackage_1012SemanticChildren(View view) {
+ if (!view.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Package modelElement = (Package) view.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getPackagedElements()
+ .iterator(); it.hasNext();) {
+ PackageableElement childElement = (PackageableElement) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == PackageEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getPackagePackagedelements_1005SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Package modelElement = (Package) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedComments()
+ .iterator(); it.hasNext();) {
+ Comment childElement = (Comment) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == CommentEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getPackagedElements()
+ .iterator(); it.hasNext();) {
+ PackageableElement childElement = (PackageableElement) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ModelEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ProfileEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PackageEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ConstraintEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == EnumerationEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == DataTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ClassEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getOwnedStereotypes()
+ .iterator(); it.hasNext();) {
+ Stereotype childElement = (Stereotype) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == StereotypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getPackagePackagedelements_11SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Package modelElement = (Package) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedComments()
+ .iterator(); it.hasNext();) {
+ Comment childElement = (Comment) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == CommentEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getPackagedElements()
+ .iterator(); it.hasNext();) {
+ PackageableElement childElement = (PackageableElement) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ModelEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ProfileEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PackageEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ConstraintEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == EnumerationEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == DataTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ClassEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getOwnedStereotypes()
+ .iterator(); it.hasNext();) {
+ Stereotype childElement = (Stereotype) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == StereotypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getProfilePackagedelements_1042SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Profile modelElement = (Profile) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedStereotypes()
+ .iterator(); it.hasNext();) {
+ Stereotype childElement = (Stereotype) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == StereotypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getPackagedElements()
+ .iterator(); it.hasNext();) {
+ PackageableElement childElement = (PackageableElement) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ModelEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ProfileEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PackageEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ConstraintEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == EnumerationEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == DataTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == MetaclassEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ClassEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getOwnedComments()
+ .iterator(); it.hasNext();) {
+ Comment childElement = (Comment) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == CommentEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getProfilePackagedelements_1051SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Profile modelElement = (Profile) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedStereotypes()
+ .iterator(); it.hasNext();) {
+ Stereotype childElement = (Stereotype) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == StereotypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getPackagedElements()
+ .iterator(); it.hasNext();) {
+ PackageableElement childElement = (PackageableElement) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ModelEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ProfileEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PackageEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ConstraintEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == EnumerationEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == DataTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == MetaclassEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ClassEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getOwnedComments()
+ .iterator(); it.hasNext();) {
+ Comment childElement = (Comment) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == CommentEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getStereotypeAttributes_1071SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Stereotype modelElement = (Stereotype) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedAttributes()
+ .iterator(); it.hasNext();) {
+ Property childElement = (Property) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ClassPropertyEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getStereotypeAttributes_1052SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Stereotype modelElement = (Stereotype) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedAttributes()
+ .iterator(); it.hasNext();) {
+ Property childElement = (Property) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ClassPropertyEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getStereotypeOperations_1019SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Stereotype modelElement = (Stereotype) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedOperations()
+ .iterator(); it.hasNext();) {
+ Operation childElement = (Operation) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ClassOperationEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getStereotypeOperations_1053SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Stereotype modelElement = (Stereotype) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedOperations()
+ .iterator(); it.hasNext();) {
+ Operation childElement = (Operation) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ClassOperationEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getModelPackagedelements_1057SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Model modelElement = (Model) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedComments()
+ .iterator(); it.hasNext();) {
+ Comment childElement = (Comment) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == CommentEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getPackagedElements()
+ .iterator(); it.hasNext();) {
+ PackageableElement childElement = (PackageableElement) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ModelEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ProfileEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PackageEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ConstraintEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == EnumerationEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == DataTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ClassEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getModelPackagedelements_1058SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Model modelElement = (Model) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedComments()
+ .iterator(); it.hasNext();) {
+ Comment childElement = (Comment) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == CommentEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ for (Iterator<?> it = modelElement.getPackagedElements()
+ .iterator(); it.hasNext();) {
+ PackageableElement childElement = (PackageableElement) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ModelEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ProfileEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PackageEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ConstraintEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == EnumerationEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == PrimitiveTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == DataTypeEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ if (visualID == ClassEditPartCN.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getEnumerationLiterals_1062SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Enumeration modelElement = (Enumeration) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedLiterals()
+ .iterator(); it.hasNext();) {
+ EnumerationLiteral childElement = (EnumerationLiteral) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == EnumerationLiteralEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getEnumerationLiterals_1063SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Enumeration modelElement = (Enumeration) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedLiterals()
+ .iterator(); it.hasNext();) {
+ EnumerationLiteral childElement = (EnumerationLiteral) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == EnumerationLiteralEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getDataTypeAttributes_1067SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ DataType modelElement = (DataType) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedAttributes()
+ .iterator(); it.hasNext();) {
+ Property childElement = (Property) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == DataTypePropertyEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getDataTypeAttributes_1069SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ DataType modelElement = (DataType) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedAttributes()
+ .iterator(); it.hasNext();) {
+ Property childElement = (Property) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == DataTypePropertyEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getDataTypeOperations_1068SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ DataType modelElement = (DataType) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedOperations()
+ .iterator(); it.hasNext();) {
+ Operation childElement = (Operation) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == DataTypeOperationEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getDataTypeOperations_1070SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ DataType modelElement = (DataType) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedOperations()
+ .iterator(); it.hasNext();) {
+ Operation childElement = (Operation) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == DataTypeOperationEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getClassAttributes_7017SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Class modelElement = (Class) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedAttributes()
+ .iterator(); it.hasNext();) {
+ Property childElement = (Property) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ClassPropertyEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getClassAttributes_7011SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Class modelElement = (Class) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedAttributes()
+ .iterator(); it.hasNext();) {
+ Property childElement = (Property) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ClassPropertyEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getClassOperations_7018SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Class modelElement = (Class) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedOperations()
+ .iterator(); it.hasNext();) {
+ Operation childElement = (Operation) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ClassOperationEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLNodeDescriptor> getClassOperations_7012SemanticChildren(View view) {
+ if (false == view.eContainer() instanceof View) {
+ return Collections.emptyList();
+ }
+ View containerView = (View) view.eContainer();
+ if (!containerView.isSetElement()) {
+ return Collections.emptyList();
+ }
+ Class modelElement = (Class) containerView.getElement();
+ LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>();
+ for (Iterator<?> it = modelElement.getOwnedOperations()
+ .iterator(); it.hasNext();) {
+ Operation childElement = (Operation) it.next();
+ int visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement);
+ if (visualID == ClassOperationEditPart.VISUAL_ID) {
+ result.add(new UMLNodeDescriptor(childElement, visualID));
+ continue;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getContainedLinks(View view) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case ProfileDiagramEditPart.VISUAL_ID:
+ return getProfile_1000ContainedLinks(view);
+ case DependencyNodeEditPart.VISUAL_ID:
+ return getDependency_2014ContainedLinks(view);
+ case AssociationNodeEditPart.VISUAL_ID:
+ return getAssociation_2015ContainedLinks(view);
+ case StereotypeEditPart.VISUAL_ID:
+ return getStereotype_1026ContainedLinks(view);
+ case ClassEditPart.VISUAL_ID:
+ return getClass_2008ContainedLinks(view);
+ case MetaclassEditPart.VISUAL_ID:
+ return getClass_1031ContainedLinks(view);
+ case CommentEditPart.VISUAL_ID:
+ return getComment_1002ContainedLinks(view);
+ case ConstraintEditPart.VISUAL_ID:
+ return getConstraint_1014ContainedLinks(view);
+ case ModelEditPartTN.VISUAL_ID:
+ return getModel_2005ContainedLinks(view);
+ case ProfileEditPartTN.VISUAL_ID:
+ return getProfile_1030ContainedLinks(view);
+ case PackageEditPart.VISUAL_ID:
+ return getPackage_2007ContainedLinks(view);
+ case EnumerationEditPart.VISUAL_ID:
+ return getEnumeration_2006ContainedLinks(view);
+ case PrimitiveTypeEditPart.VISUAL_ID:
+ return getPrimitiveType_2009ContainedLinks(view);
+ case DataTypeEditPart.VISUAL_ID:
+ return getDataType_2010ContainedLinks(view);
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ return getDiagram_2016ContainedLinks(view);
+ case PrimitiveTypeEditPartCN.VISUAL_ID:
+ return getPrimitiveType_3026ContainedLinks(view);
+ case DataTypeOperationEditPart.VISUAL_ID:
+ return getOperation_3019ContainedLinks(view);
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ return getEnumerationLiteral_1037ContainedLinks(view);
+ case DataTypePropertyEditPart.VISUAL_ID:
+ return getProperty_3018ContainedLinks(view);
+ case ClassPropertyEditPart.VISUAL_ID:
+ return getProperty_3002ContainedLinks(view);
+ case ClassOperationEditPart.VISUAL_ID:
+ return getOperation_3020ContainedLinks(view);
+ case StereotypeEditPartCN.VISUAL_ID:
+ return getStereotype_1023ContainedLinks(view);
+ case ClassEditPartCN.VISUAL_ID:
+ return getClass_3010ContainedLinks(view);
+ case MetaclassEditPartCN.VISUAL_ID:
+ return getClass_3028ContainedLinks(view);
+ case CommentEditPartCN.VISUAL_ID:
+ return getComment_1007ContainedLinks(view);
+ case ModelEditPartCN.VISUAL_ID:
+ return getModel_1027ContainedLinks(view);
+ case ProfileEditPartCN.VISUAL_ID:
+ return getProfile_1024ContainedLinks(view);
+ case PackageEditPartCN.VISUAL_ID:
+ return getPackage_1012ContainedLinks(view);
+ case ConstraintEditPartCN.VISUAL_ID:
+ return getConstraint_1028ContainedLinks(view);
+ case EnumerationEditPartCN.VISUAL_ID:
+ return getEnumeration_3025ContainedLinks(view);
+ case DataTypeEditPartCN.VISUAL_ID:
+ return getDataType_3027ContainedLinks(view);
+ case ExtensionEditPart.VISUAL_ID:
+ return getExtension_1013ContainedLinks(view);
+ case AssociationEditPart.VISUAL_ID:
+ return getAssociation_4001ContainedLinks(view);
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return getProfileApplication_1045ContainedLinks(view);
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getAssociation_4019ContainedLinks(view);
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGeneralization_4002ContainedLinks(view);
+ case DependencyEditPart.VISUAL_ID:
+ return getDependency_4008ContainedLinks(view);
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getDependency_4018ContainedLinks(view);
+ case ElementImportEditPart.VISUAL_ID:
+ return getElementImport_1064ContainedLinks(view);
+ case PackageImportEditPart.VISUAL_ID:
+ return getPackageImport_1065ContainedLinks(view);
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getIncomingLinks(View view) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case DependencyNodeEditPart.VISUAL_ID:
+ return getDependency_2014IncomingLinks(view);
+ case AssociationNodeEditPart.VISUAL_ID:
+ return getAssociation_2015IncomingLinks(view);
+ case StereotypeEditPart.VISUAL_ID:
+ return getStereotype_1026IncomingLinks(view);
+ case ClassEditPart.VISUAL_ID:
+ return getClass_2008IncomingLinks(view);
+ case MetaclassEditPart.VISUAL_ID:
+ return getClass_1031IncomingLinks(view);
+ case CommentEditPart.VISUAL_ID:
+ return getComment_1002IncomingLinks(view);
+ case ConstraintEditPart.VISUAL_ID:
+ return getConstraint_1014IncomingLinks(view);
+ case ModelEditPartTN.VISUAL_ID:
+ return getModel_2005IncomingLinks(view);
+ case ProfileEditPartTN.VISUAL_ID:
+ return getProfile_1030IncomingLinks(view);
+ case PackageEditPart.VISUAL_ID:
+ return getPackage_2007IncomingLinks(view);
+ case EnumerationEditPart.VISUAL_ID:
+ return getEnumeration_2006IncomingLinks(view);
+ case PrimitiveTypeEditPart.VISUAL_ID:
+ return getPrimitiveType_2009IncomingLinks(view);
+ case DataTypeEditPart.VISUAL_ID:
+ return getDataType_2010IncomingLinks(view);
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ return getDiagram_2016IncomingLinks(view);
+ case PrimitiveTypeEditPartCN.VISUAL_ID:
+ return getPrimitiveType_3026IncomingLinks(view);
+ case DataTypeOperationEditPart.VISUAL_ID:
+ return getOperation_3019IncomingLinks(view);
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ return getEnumerationLiteral_1037IncomingLinks(view);
+ case DataTypePropertyEditPart.VISUAL_ID:
+ return getProperty_3018IncomingLinks(view);
+ case ClassPropertyEditPart.VISUAL_ID:
+ return getProperty_3002IncomingLinks(view);
+ case ClassOperationEditPart.VISUAL_ID:
+ return getOperation_3020IncomingLinks(view);
+ case StereotypeEditPartCN.VISUAL_ID:
+ return getStereotype_1023IncomingLinks(view);
+ case ClassEditPartCN.VISUAL_ID:
+ return getClass_3010IncomingLinks(view);
+ case MetaclassEditPartCN.VISUAL_ID:
+ return getClass_3028IncomingLinks(view);
+ case CommentEditPartCN.VISUAL_ID:
+ return getComment_1007IncomingLinks(view);
+ case ModelEditPartCN.VISUAL_ID:
+ return getModel_1027IncomingLinks(view);
+ case ProfileEditPartCN.VISUAL_ID:
+ return getProfile_1024IncomingLinks(view);
+ case PackageEditPartCN.VISUAL_ID:
+ return getPackage_1012IncomingLinks(view);
+ case ConstraintEditPartCN.VISUAL_ID:
+ return getConstraint_1028IncomingLinks(view);
+ case EnumerationEditPartCN.VISUAL_ID:
+ return getEnumeration_3025IncomingLinks(view);
+ case DataTypeEditPartCN.VISUAL_ID:
+ return getDataType_3027IncomingLinks(view);
+ case ExtensionEditPart.VISUAL_ID:
+ return getExtension_1013IncomingLinks(view);
+ case AssociationEditPart.VISUAL_ID:
+ return getAssociation_4001IncomingLinks(view);
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return getProfileApplication_1045IncomingLinks(view);
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getAssociation_4019IncomingLinks(view);
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGeneralization_4002IncomingLinks(view);
+ case DependencyEditPart.VISUAL_ID:
+ return getDependency_4008IncomingLinks(view);
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getDependency_4018IncomingLinks(view);
+ case ElementImportEditPart.VISUAL_ID:
+ return getElementImport_1064IncomingLinks(view);
+ case PackageImportEditPart.VISUAL_ID:
+ return getPackageImport_1065IncomingLinks(view);
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getOutgoingLinks(View view) {
+ switch (UMLVisualIDRegistry.getVisualID(view)) {
+ case DependencyNodeEditPart.VISUAL_ID:
+ return getDependency_2014OutgoingLinks(view);
+ case AssociationNodeEditPart.VISUAL_ID:
+ return getAssociation_2015OutgoingLinks(view);
+ case StereotypeEditPart.VISUAL_ID:
+ return getStereotype_1026OutgoingLinks(view);
+ case ClassEditPart.VISUAL_ID:
+ return getClass_2008OutgoingLinks(view);
+ case MetaclassEditPart.VISUAL_ID:
+ return getClass_1031OutgoingLinks(view);
+ case CommentEditPart.VISUAL_ID:
+ return getComment_1002OutgoingLinks(view);
+ case ConstraintEditPart.VISUAL_ID:
+ return getConstraint_1014OutgoingLinks(view);
+ case ModelEditPartTN.VISUAL_ID:
+ return getModel_2005OutgoingLinks(view);
+ case ProfileEditPartTN.VISUAL_ID:
+ return getProfile_1030OutgoingLinks(view);
+ case PackageEditPart.VISUAL_ID:
+ return getPackage_2007OutgoingLinks(view);
+ case EnumerationEditPart.VISUAL_ID:
+ return getEnumeration_2006OutgoingLinks(view);
+ case PrimitiveTypeEditPart.VISUAL_ID:
+ return getPrimitiveType_2009OutgoingLinks(view);
+ case DataTypeEditPart.VISUAL_ID:
+ return getDataType_2010OutgoingLinks(view);
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ return getDiagram_2016OutgoingLinks(view);
+ case PrimitiveTypeEditPartCN.VISUAL_ID:
+ return getPrimitiveType_3026OutgoingLinks(view);
+ case DataTypeOperationEditPart.VISUAL_ID:
+ return getOperation_3019OutgoingLinks(view);
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ return getEnumerationLiteral_1037OutgoingLinks(view);
+ case DataTypePropertyEditPart.VISUAL_ID:
+ return getProperty_3018OutgoingLinks(view);
+ case ClassPropertyEditPart.VISUAL_ID:
+ return getProperty_3002OutgoingLinks(view);
+ case ClassOperationEditPart.VISUAL_ID:
+ return getOperation_3020OutgoingLinks(view);
+ case StereotypeEditPartCN.VISUAL_ID:
+ return getStereotype_1023OutgoingLinks(view);
+ case ClassEditPartCN.VISUAL_ID:
+ return getClass_3010OutgoingLinks(view);
+ case MetaclassEditPartCN.VISUAL_ID:
+ return getClass_3028OutgoingLinks(view);
+ case CommentEditPartCN.VISUAL_ID:
+ return getComment_1007OutgoingLinks(view);
+ case ModelEditPartCN.VISUAL_ID:
+ return getModel_1027OutgoingLinks(view);
+ case ProfileEditPartCN.VISUAL_ID:
+ return getProfile_1024OutgoingLinks(view);
+ case PackageEditPartCN.VISUAL_ID:
+ return getPackage_1012OutgoingLinks(view);
+ case ConstraintEditPartCN.VISUAL_ID:
+ return getConstraint_1028OutgoingLinks(view);
+ case EnumerationEditPartCN.VISUAL_ID:
+ return getEnumeration_3025OutgoingLinks(view);
+ case DataTypeEditPartCN.VISUAL_ID:
+ return getDataType_3027OutgoingLinks(view);
+ case ExtensionEditPart.VISUAL_ID:
+ return getExtension_1013OutgoingLinks(view);
+ case AssociationEditPart.VISUAL_ID:
+ return getAssociation_4001OutgoingLinks(view);
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return getProfileApplication_1045OutgoingLinks(view);
+ case AssociationBranchEditPart.VISUAL_ID:
+ return getAssociation_4019OutgoingLinks(view);
+ case GeneralizationEditPart.VISUAL_ID:
+ return getGeneralization_4002OutgoingLinks(view);
+ case DependencyEditPart.VISUAL_ID:
+ return getDependency_4008OutgoingLinks(view);
+ case DependencyBranchEditPart.VISUAL_ID:
+ return getDependency_4018OutgoingLinks(view);
+ case ElementImportEditPart.VISUAL_ID:
+ return getElementImport_1064OutgoingLinks(view);
+ case PackageImportEditPart.VISUAL_ID:
+ return getPackageImport_1065OutgoingLinks(view);
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProfile_1000ContainedLinks(View view) {
+ Profile modelElement = (Profile) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Extension_1013
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDependency_2014ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getAssociation_2015ContainedLinks(View view) {
+ Association modelElement = (Association) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getStereotype_1026ContainedLinks(View view) {
+ Stereotype modelElement = (Stereotype) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_2008ContainedLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_1031ContainedLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getComment_1002ContainedLinks(View view) {
+ Comment modelElement = (Comment) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getConstraint_1014ContainedLinks(View view) {
+ Constraint modelElement = (Constraint) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement));
+ result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getModel_2005ContainedLinks(View view) {
+ Model modelElement = (Model) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Extension_1013
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProfile_1030ContainedLinks(View view) {
+ Profile modelElement = (Profile) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Extension_1013
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPackage_2007ContainedLinks(View view) {
+ Package modelElement = (Package) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Extension_1013
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getEnumeration_2006ContainedLinks(View view) {
+ Enumeration modelElement = (Enumeration) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPrimitiveType_2009ContainedLinks(View view) {
+ PrimitiveType modelElement = (PrimitiveType) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDataType_2010ContainedLinks(View view) {
+ DataType modelElement = (DataType) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDiagram_2016ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPrimitiveType_3026ContainedLinks(View view) {
+ PrimitiveType modelElement = (PrimitiveType) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getOperation_3019ContainedLinks(View view) {
+ Operation modelElement = (Operation) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getEnumerationLiteral_1037ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProperty_3018ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProperty_3002ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getOperation_3020ContainedLinks(View view) {
+ Operation modelElement = (Operation) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getStereotype_1023ContainedLinks(View view) {
+ Stereotype modelElement = (Stereotype) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_3010ContainedLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_3028ContainedLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getComment_1007ContainedLinks(View view) {
+ Comment modelElement = (Comment) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getModel_1027ContainedLinks(View view) {
+ Model modelElement = (Model) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Extension_1013
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProfile_1024ContainedLinks(View view) {
+ Profile modelElement = (Profile) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Extension_1013
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPackage_1012ContainedLinks(View view) {
+ Package modelElement = (Package) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Extension_1013
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getConstraint_1028ContainedLinks(View view) {
+ Constraint modelElement = (Constraint) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement));
+ result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getEnumeration_3025ContainedLinks(View view) {
+ Enumeration modelElement = (Enumeration) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDataType_3027ContainedLinks(View view) {
+ DataType modelElement = (DataType) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getExtension_1013ContainedLinks(View view) {
+ Extension modelElement = (Extension) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getAssociation_4001ContainedLinks(View view) {
+ Association modelElement = (Association) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProfileApplication_1045ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getAssociation_4019ContainedLinks(View view) {
+ Association modelElement = (Association) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getGeneralization_4002ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDependency_4008ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDependency_4018ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getElementImport_1064ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPackageImport_1065ContainedLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDependency_2014IncomingLinks(View view) {
+ Dependency modelElement = (Dependency) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getAssociation_2015IncomingLinks(View view) {
+ Association modelElement = (Association) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getStereotype_1026IncomingLinks(View view) {
+ Stereotype modelElement = (Stereotype) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Extension_1013
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_2008IncomingLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Extension_1013
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_1031IncomingLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Extension_1013
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getComment_1002IncomingLinks(View view) {
+ Comment modelElement = (Comment) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getConstraint_1014IncomingLinks(View view) {
+ Constraint modelElement = (Constraint) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getModel_2005IncomingLinks(View view) {
+ Model modelElement = (Model) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProfile_1030IncomingLinks(View view) {
+ Profile modelElement = (Profile) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPackage_2007IncomingLinks(View view) {
+ Package modelElement = (Package) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getEnumeration_2006IncomingLinks(View view) {
+ Enumeration modelElement = (Enumeration) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPrimitiveType_2009IncomingLinks(View view) {
+ PrimitiveType modelElement = (PrimitiveType) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDataType_2010IncomingLinks(View view) {
+ DataType modelElement = (DataType) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDiagram_2016IncomingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPrimitiveType_3026IncomingLinks(View view) {
+ PrimitiveType modelElement = (PrimitiveType) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getOperation_3019IncomingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getEnumerationLiteral_1037IncomingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProperty_3018IncomingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProperty_3002IncomingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getOperation_3020IncomingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getStereotype_1023IncomingLinks(View view) {
+ Stereotype modelElement = (Stereotype) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Extension_1013
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_3010IncomingLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Extension_1013
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_3028IncomingLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Extension_1013
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getComment_1007IncomingLinks(View view) {
+ Comment modelElement = (Comment) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getModel_1027IncomingLinks(View view) {
+ Model modelElement = (Model) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProfile_1024IncomingLinks(View view) {
+ Profile modelElement = (Profile) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPackage_1012IncomingLinks(View view) {
+ Package modelElement = (Package) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_PackageImport_1065
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getConstraint_1028IncomingLinks(View view) {
+ Constraint modelElement = (Constraint) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getEnumeration_3025IncomingLinks(View view) {
+ Enumeration modelElement = (Enumeration) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDataType_3027IncomingLinks(View view) {
+ DataType modelElement = (DataType) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getExtension_1013IncomingLinks(View view) {
+ Extension modelElement = (Extension) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getAssociation_4001IncomingLinks(View view) {
+ Association modelElement = (Association) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProfileApplication_1045IncomingLinks(View view) {
+ ProfileApplication modelElement = (ProfileApplication) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getAssociation_4019IncomingLinks(View view) {
+ Association modelElement = (Association) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4001
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Association_4019
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Generalization_4002
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getGeneralization_4002IncomingLinks(View view) {
+ Generalization modelElement = (Generalization) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDependency_4008IncomingLinks(View view) {
+ Dependency modelElement = (Dependency) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDependency_4018IncomingLinks(View view) {
+ Dependency modelElement = (Dependency) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4008
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_Dependency_4018
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingTypeModelFacetLinks_ElementImport_1064
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getElementImport_1064IncomingLinks(View view) {
+ ElementImport modelElement = (ElementImport) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPackageImport_1065IncomingLinks(View view) {
+ PackageImport modelElement = (PackageImport) view.getElement();
+ CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet());
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement, crossReferencer));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement, crossReferencer));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDependency_2014OutgoingLinks(View view) {
+ Dependency modelElement = (Dependency) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getAssociation_2015OutgoingLinks(View view) {
+ Association modelElement = (Association) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getStereotype_1026OutgoingLinks(View view) {
+ Stereotype modelElement = (Stereotype) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_2008OutgoingLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_1031OutgoingLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getComment_1002OutgoingLinks(View view) {
+ Comment modelElement = (Comment) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getConstraint_1014OutgoingLinks(View view) {
+ Constraint modelElement = (Constraint) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement));
+ result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getModel_2005OutgoingLinks(View view) {
+ Model modelElement = (Model) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProfile_1030OutgoingLinks(View view) {
+ Profile modelElement = (Profile) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPackage_2007OutgoingLinks(View view) {
+ Package modelElement = (Package) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getEnumeration_2006OutgoingLinks(View view) {
+ Enumeration modelElement = (Enumeration) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPrimitiveType_2009OutgoingLinks(View view) {
+ PrimitiveType modelElement = (PrimitiveType) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDataType_2010OutgoingLinks(View view) {
+ DataType modelElement = (DataType) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDiagram_2016OutgoingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPrimitiveType_3026OutgoingLinks(View view) {
+ PrimitiveType modelElement = (PrimitiveType) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getOperation_3019OutgoingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getEnumerationLiteral_1037OutgoingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProperty_3018OutgoingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProperty_3002OutgoingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getOperation_3020OutgoingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getStereotype_1023OutgoingLinks(View view) {
+ Stereotype modelElement = (Stereotype) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_3010OutgoingLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getClass_3028OutgoingLinks(View view) {
+ Class modelElement = (Class) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getComment_1007OutgoingLinks(View view) {
+ Comment modelElement = (Comment) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_1022
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getModel_1027OutgoingLinks(View view) {
+ Model modelElement = (Model) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProfile_1024OutgoingLinks(View view) {
+ Profile modelElement = (Profile) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPackage_1012OutgoingLinks(View view) {
+ Package modelElement = (Package) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_ProfileApplication_1045
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getConstraint_1028OutgoingLinks(View view) {
+ Constraint modelElement = (Constraint) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014
+ (modelElement));
+ result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_Context_8500
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getEnumeration_3025OutgoingLinks(View view) {
+ Enumeration modelElement = (Enumeration) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDataType_3027OutgoingLinks(View view) {
+ DataType modelElement = (DataType) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getExtension_1013OutgoingLinks(View view) {
+ Extension modelElement = (Extension) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getAssociation_4001OutgoingLinks(View view) {
+ Association modelElement = (Association) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getProfileApplication_1045OutgoingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getAssociation_4019OutgoingLinks(View view) {
+ Association modelElement = (Association) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4001
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Association_4019
+ (modelElement));
+ result.addAll(getContainedTypeModelFacetLinks_Generalization_4002
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_ElementImport_1064
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_PackageImport_1065
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getGeneralization_4002OutgoingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDependency_4008OutgoingLinks(View view) {
+ Dependency modelElement = (Dependency) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getDependency_4018OutgoingLinks(View view) {
+ Dependency modelElement = (Dependency) view.getElement();
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4008
+ (modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_4018
+ (modelElement));
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getElementImport_1064OutgoingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ public List<UMLLinkDescriptor> getPackageImport_1065OutgoingLinks(View view) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Extension_1013(Package container) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackagedElements()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof Extension) {
+ continue;
+ }
+ Extension link = (Extension) linkObject;
+ if (ExtensionEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ Class dst = link.getMetaclass();
+ List<?> sources = link.getOwnedEnds();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof Property) {
+ continue;
+ }
+ Property src = (Property) theSource;
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Extension_1013, ExtensionEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Association_4001(Package container) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackagedElements()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof Association) {
+ continue;
+ }
+ Association link = (Association) linkObject;
+ if (AssociationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> targets = link.getEndTypes();
+ Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+ if (false == theTarget instanceof Type) {
+ continue;
+ }
+ Type dst = (Type) theTarget;
+ List<?> sources = link.getEndTypes();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof Type) {
+ continue;
+ }
+ Type src = (Type) theSource;
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Association_4001, AssociationEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_ProfileApplication_1045(Package container) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getProfileApplications()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof ProfileApplication) {
+ continue;
+ }
+ ProfileApplication link = (ProfileApplication) linkObject;
+ if (ProfileApplicationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ Profile dst = link.getAppliedProfile();
+ Package src = link.getApplyingPackage();
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.ProfileApplication_1045, ProfileApplicationEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Association_4019(Package container) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackagedElements()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof Association) {
+ continue;
+ }
+ Association link = (Association) linkObject;
+ if (AssociationBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> targets = link.getEndTypes();
+ Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+ if (false == theTarget instanceof Type) {
+ continue;
+ }
+ Type dst = (Type) theTarget;
+ List<?> sources = link.getEndTypes();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof Type) {
+ continue;
+ }
+ Type src = (Type) theSource;
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Association_4019, AssociationBranchEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Generalization_4002(Classifier container) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getGeneralizations()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof Generalization) {
+ continue;
+ }
+ Generalization link = (Generalization) linkObject;
+ if (GeneralizationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ Classifier dst = link.getGeneral();
+ result.add(new UMLLinkDescriptor(container, dst, link, UMLElementTypes.Generalization_4002, GeneralizationEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Dependency_4008(Package container) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackagedElements()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof Dependency) {
+ continue;
+ }
+ Dependency link = (Dependency) linkObject;
+ if (DependencyEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> targets = link.getSuppliers();
+ Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+ if (false == theTarget instanceof NamedElement) {
+ continue;
+ }
+ NamedElement dst = (NamedElement) theTarget;
+ List<?> sources = link.getClients();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof NamedElement) {
+ continue;
+ }
+ NamedElement src = (NamedElement) theSource;
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Dependency_4008, DependencyEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Dependency_4018(Package container) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackagedElements()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof Dependency) {
+ continue;
+ }
+ Dependency link = (Dependency) linkObject;
+ if (DependencyBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> targets = link.getSuppliers();
+ Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+ if (false == theTarget instanceof NamedElement) {
+ continue;
+ }
+ NamedElement dst = (NamedElement) theTarget;
+ List<?> sources = link.getClients();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof NamedElement) {
+ continue;
+ }
+ NamedElement src = (NamedElement) theSource;
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Dependency_4018, DependencyBranchEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_ElementImport_1064(Namespace container) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getElementImports()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof ElementImport) {
+ continue;
+ }
+ ElementImport link = (ElementImport) linkObject;
+ if (ElementImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ PackageableElement dst = link.getImportedElement();
+ Namespace src = link.getImportingNamespace();
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.ElementImport_1064, ElementImportEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_PackageImport_1065(Namespace container) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackageImports()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof PackageImport) {
+ continue;
+ }
+ PackageImport link = (PackageImport) linkObject;
+ if (PackageImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ Package dst = link.getImportedPackage();
+ Namespace src = link.getImportingNamespace();
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.PackageImport_1065, PackageImportEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Extension_1013(Class target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getExtension_Metaclass() || false == setting.getEObject() instanceof Extension) {
+ continue;
+ }
+ Extension link = (Extension) setting.getEObject();
+ if (ExtensionEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> sources = link.getOwnedEnds();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof Property) {
+ continue;
+ }
+ Property src = (Property) theSource;
+ result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Extension_1013, ExtensionEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Association_4001(Type target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getAssociation_EndType() || false == setting.getEObject() instanceof Association) {
+ continue;
+ }
+ Association link = (Association) setting.getEObject();
+ if (AssociationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> sources = link.getEndTypes();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof Type) {
+ continue;
+ }
+ Type src = (Type) theSource;
+ result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Association_4001, AssociationEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_ProfileApplication_1045(Profile target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getProfileApplication_AppliedProfile() || false == setting.getEObject() instanceof ProfileApplication) {
+ continue;
+ }
+ ProfileApplication link = (ProfileApplication) setting.getEObject();
+ if (ProfileApplicationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ Package src = link.getApplyingPackage();
+ result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.ProfileApplication_1045, ProfileApplicationEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Association_4019(Type target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getAssociation_EndType() || false == setting.getEObject() instanceof Association) {
+ continue;
+ }
+ Association link = (Association) setting.getEObject();
+ if (AssociationBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> sources = link.getEndTypes();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof Type) {
+ continue;
+ }
+ Type src = (Type) theSource;
+ result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Association_4019, AssociationBranchEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Generalization_4002(Classifier target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getGeneralization_General() || false == setting.getEObject() instanceof Generalization) {
+ continue;
+ }
+ Generalization link = (Generalization) setting.getEObject();
+ if (GeneralizationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ if (false == link.eContainer() instanceof Classifier) {
+ continue;
+ }
+ Classifier container = (Classifier) link.eContainer();
+ result.add(new UMLLinkDescriptor(container, target, link, UMLElementTypes.Generalization_4002, GeneralizationEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Dependency_4008(NamedElement target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getDependency_Supplier() || false == setting.getEObject() instanceof Dependency) {
+ continue;
+ }
+ Dependency link = (Dependency) setting.getEObject();
+ if (DependencyEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> sources = link.getClients();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof NamedElement) {
+ continue;
+ }
+ NamedElement src = (NamedElement) theSource;
+ result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Dependency_4008, DependencyEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Dependency_4018(NamedElement target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getDependency_Supplier() || false == setting.getEObject() instanceof Dependency) {
+ continue;
+ }
+ Dependency link = (Dependency) setting.getEObject();
+ if (DependencyBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> sources = link.getClients();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof NamedElement) {
+ continue;
+ }
+ NamedElement src = (NamedElement) theSource;
+ result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Dependency_4018, DependencyBranchEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_ElementImport_1064(PackageableElement target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getElementImport_ImportedElement() || false == setting.getEObject() instanceof ElementImport) {
+ continue;
+ }
+ ElementImport link = (ElementImport) setting.getEObject();
+ if (ElementImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ Namespace src = link.getImportingNamespace();
+ result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.ElementImport_1064, ElementImportEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_PackageImport_1065(Package target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getPackageImport_ImportedPackage() || false == setting.getEObject() instanceof PackageImport) {
+ continue;
+ }
+ PackageImport link = (PackageImport) setting.getEObject();
+ if (PackageImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ Namespace src = link.getImportingNamespace();
+ result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.PackageImport_1065, PackageImportEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(Element target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getComment_AnnotatedElement()) {
+ result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.CommentAnnotatedElement_1022, CommentAnnotatedElementEditPart.VISUAL_ID));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(Element target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getConstraint_ConstrainedElement()) {
+ result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.ConstraintConstrainedElement_4014, ConstraintConstrainedElementEditPart.VISUAL_ID));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Constraint_Context_8500(Namespace target, CrossReferenceAdapter crossReferencer) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (EStructuralFeature.Setting setting : settings) {
+ if (setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getConstraint_Context()) {
+ result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.ConstraintContext_8500, ContextLinkEditPart.VISUAL_ID));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_Association_4001(Type source) {
+ Package container = null;
+ // Find container element for the 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 && container == null; element = element.eContainer()) {
+ if (element instanceof Package) {
+ container = (Package) element;
+ }
+ }
+ if (container == null) {
+ return Collections.emptyList();
+ }
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackagedElements()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof Association) {
+ continue;
+ }
+ Association link = (Association) linkObject;
+ if (AssociationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> targets = link.getEndTypes();
+ Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+ if (false == theTarget instanceof Type) {
+ continue;
+ }
+ Type dst = (Type) theTarget;
+ List<?> sources = link.getEndTypes();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof Type) {
+ continue;
+ }
+ Type src = (Type) theSource;
+ if (src != source) {
+ continue;
+ }
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Association_4001, AssociationEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_ProfileApplication_1045(Package source) {
+ Package container = null;
+ // Find container element for the 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 && container == null; element = element.eContainer()) {
+ if (element instanceof Package) {
+ container = (Package) element;
+ }
+ }
+ if (container == null) {
+ return Collections.emptyList();
+ }
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getProfileApplications()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof ProfileApplication) {
+ continue;
+ }
+ ProfileApplication link = (ProfileApplication) linkObject;
+ if (ProfileApplicationEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ Profile dst = link.getAppliedProfile();
+ Package src = link.getApplyingPackage();
+ if (src != source) {
+ continue;
+ }
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.ProfileApplication_1045, ProfileApplicationEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_Association_4019(Type source) {
+ Package container = null;
+ // Find container element for the 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 && container == null; element = element.eContainer()) {
+ if (element instanceof Package) {
+ container = (Package) element;
+ }
+ }
+ if (container == null) {
+ return Collections.emptyList();
+ }
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackagedElements()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof Association) {
+ continue;
+ }
+ Association link = (Association) linkObject;
+ if (AssociationBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> targets = link.getEndTypes();
+ Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+ if (false == theTarget instanceof Type) {
+ continue;
+ }
+ Type dst = (Type) theTarget;
+ List<?> sources = link.getEndTypes();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof Type) {
+ continue;
+ }
+ Type src = (Type) theSource;
+ if (src != source) {
+ continue;
+ }
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Association_4019, AssociationBranchEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_Dependency_4008(NamedElement source) {
+ Package container = null;
+ // Find container element for the 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 && container == null; element = element.eContainer()) {
+ if (element instanceof Package) {
+ container = (Package) element;
+ }
+ }
+ if (container == null) {
+ return Collections.emptyList();
+ }
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackagedElements()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof Dependency) {
+ continue;
+ }
+ Dependency link = (Dependency) linkObject;
+ if (DependencyEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> targets = link.getSuppliers();
+ Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+ if (false == theTarget instanceof NamedElement) {
+ continue;
+ }
+ NamedElement dst = (NamedElement) theTarget;
+ List<?> sources = link.getClients();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof NamedElement) {
+ continue;
+ }
+ NamedElement src = (NamedElement) theSource;
+ if (src != source) {
+ continue;
+ }
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Dependency_4008, DependencyEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_Dependency_4018(NamedElement source) {
+ Package container = null;
+ // Find container element for the 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 && container == null; element = element.eContainer()) {
+ if (element instanceof Package) {
+ container = (Package) element;
+ }
+ }
+ if (container == null) {
+ return Collections.emptyList();
+ }
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackagedElements()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof Dependency) {
+ continue;
+ }
+ Dependency link = (Dependency) linkObject;
+ if (DependencyBranchEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ List<?> targets = link.getSuppliers();
+ Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+ if (false == theTarget instanceof NamedElement) {
+ continue;
+ }
+ NamedElement dst = (NamedElement) theTarget;
+ List<?> sources = link.getClients();
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if (false == theSource instanceof NamedElement) {
+ continue;
+ }
+ NamedElement src = (NamedElement) theSource;
+ if (src != source) {
+ continue;
+ }
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Dependency_4018, DependencyBranchEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_ElementImport_1064(Namespace source) {
+ Namespace container = null;
+ // Find container element for the 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 && container == null; element = element.eContainer()) {
+ if (element instanceof Namespace) {
+ container = (Namespace) element;
+ }
+ }
+ if (container == null) {
+ return Collections.emptyList();
+ }
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getElementImports()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof ElementImport) {
+ continue;
+ }
+ ElementImport link = (ElementImport) linkObject;
+ if (ElementImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ PackageableElement dst = link.getImportedElement();
+ Namespace src = link.getImportingNamespace();
+ if (src != source) {
+ continue;
+ }
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.ElementImport_1064, ElementImportEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_PackageImport_1065(Namespace source) {
+ Namespace container = null;
+ // Find container element for the 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 && container == null; element = element.eContainer()) {
+ if (element instanceof Namespace) {
+ container = (Namespace) element;
+ }
+ }
+ if (container == null) {
+ return Collections.emptyList();
+ }
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> links = container.getPackageImports()
+ .iterator(); links.hasNext();) {
+ EObject linkObject = (EObject) links.next();
+ if (false == linkObject instanceof PackageImport) {
+ continue;
+ }
+ PackageImport link = (PackageImport) linkObject;
+ if (PackageImportEditPart.VISUAL_ID != UMLVisualIDRegistry.getLinkWithClassVisualID(link)) {
+ continue;
+ }
+ Package dst = link.getImportedPackage();
+ Namespace src = link.getImportingNamespace();
+ if (src != source) {
+ continue;
+ }
+ result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.PackageImport_1065, PackageImportEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_1022(Comment source) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> destinations = source.getAnnotatedElements()
+ .iterator(); destinations.hasNext();) {
+ Element destination = (Element) destinations.next();
+ result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.CommentAnnotatedElement_1022, CommentAnnotatedElementEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4014(Constraint source) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for (Iterator<?> destinations = source.getConstrainedElements()
+ .iterator(); destinations.hasNext();) {
+ Element destination = (Element) destinations.next();
+ result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.ConstraintConstrainedElement_4014, ConstraintConstrainedElementEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Constraint_Context_8500(Constraint source) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ Namespace destination = source.getContext();
+ if (destination == null) {
+ return result;
+ }
+ result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.ConstraintContext_8500, ContextLinkEditPart.VISUAL_ID));
+ return result;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDocumentProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDocumentProvider.java
index 55b6397b1c7..c4a5386bece 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDocumentProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDocumentProvider.java
@@ -1,1002 +1,1014 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import java.io.IOException;
-import java.util.ArrayList;
-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.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.MultiRule;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.ui.URIEditorInput;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EContentAdapter;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.transaction.NotificationFilter;
-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.DiagramEditingDomainFactory;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.EditorStatusCodes;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.util.DiagramIOUtil;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.part.FileEditorInput;
-
-/**
- * @generated
- */
-public class UMLDocumentProvider extends AbstractDocumentProvider implements IDiagramDocumentProvider {
-
- /**
- * @generated
- */
- @Override
- protected ElementInfo createElementInfo(Object element) throws CoreException {
- if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) {
- throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0,
- NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
- null));
- }
- IEditorInput editorInput = (IEditorInput) element;
- IDiagramDocument document = (IDiagramDocument) createDocument(editorInput);
- ResourceSetInfo info = new ResourceSetInfo(document, editorInput);
- info.setModificationStamp(computeModificationStamp(info));
- info.fStatus = null;
- return info;
- }
-
- /**
- * @generated
- */
- @Override
- protected IDocument createDocument(Object element) throws CoreException {
- if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) {
- throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0,
- NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
- null));
- }
- IDocument document = createEmptyDocument();
- setDocumentContent(document, (IEditorInput) element);
- setupDocument(element, document);
- return document;
- }
-
- /**
- * Sets up the given document as it would be provided for the given element. The
- * content of the document is not changed. This default implementation is empty.
- * Subclasses may reimplement.
- *
- * @param element
- * the blue-print element
- * @param document
- * the document to set up
- * @generated
- */
- protected void setupDocument(Object element, IDocument document) {
- // for subclasses
- }
-
- /**
- * @generated
- */
- private long computeModificationStamp(ResourceSetInfo info) {
- int result = 0;
- for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
- Resource nextResource = it.next();
- IFile file = WorkspaceSynchronizer.getFile(nextResource);
- if (file != null) {
- if (file.getLocation() != null) {
- result += file.getLocation().toFile().lastModified();
- } else {
- result += file.getModificationStamp();
- }
- }
- }
- return result;
- }
-
- /**
- * @generated
- */
- @Override
- protected IDocument createEmptyDocument() {
- DiagramDocument document = new DiagramDocument();
- document.setEditingDomain(createEditingDomain());
- return document;
- }
-
- /**
- * @generated
- */
- private TransactionalEditingDomain createEditingDomain() {
- TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain();
- editingDomain.setID("org.eclipse.papyrus.uml.diagram.profile.EditingDomain"); //$NON-NLS-1$
- final NotificationFilter diagramResourceModifiedFilter = NotificationFilter.createNotifierFilter(editingDomain.getResourceSet()).and(NotificationFilter.createEventTypeFilter(Notification.ADD))
- .and(NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES));
- editingDomain.getResourceSet().eAdapters().add(new Adapter() {
-
- private Notifier myTarger;
-
- public Notifier getTarget() {
- return myTarger;
- }
-
- public boolean isAdapterForType(Object type) {
- return false;
- }
-
- public void notifyChanged(Notification notification) {
- if (diagramResourceModifiedFilter.matches(notification)) {
- Object value = notification.getNewValue();
- if (value instanceof Resource) {
- ((Resource) value).setTrackingModification(true);
- }
- }
- }
-
- public void setTarget(Notifier newTarget) {
- myTarger = newTarget;
- }
- });
- return editingDomain;
- }
-
- /**
- * @generated
- */
- protected void setDocumentContent(IDocument document, IEditorInput element) throws CoreException {
- IDiagramDocument diagramDocument = (IDiagramDocument) document;
- TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
- if (element instanceof FileEditorInput) {
- IStorage storage = ((FileEditorInput) element).getStorage();
- Diagram diagram = DiagramIOUtil.load(domain, storage, true, getProgressMonitor());
- document.setContent(diagram);
- } else if (element instanceof URIEditorInput) {
- URI uri = ((URIEditorInput) element).getURI();
- Resource resource = null;
- try {
- resource = domain.getResourceSet().getResource(uri.trimFragment(), false);
- if (resource == null) {
- resource = domain.getResourceSet().createResource(uri.trimFragment());
- }
- if (!resource.isLoaded()) {
- try {
- @SuppressWarnings({ "rawtypes", "unchecked" })
- Map<?, ?> options = new HashMap(GMFResourceFactory.getDefaultLoadOptions());
- // @see 171060
- // options.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
- resource.load(options);
- } catch (IOException e) {
- resource.unload();
- throw e;
- }
- }
- if (uri.fragment() != null) {
- EObject rootElement = resource.getEObject(uri.fragment());
- if (rootElement instanceof Diagram) {
- document.setContent(rootElement);
- return;
- }
- } else {
- for (Iterator<EObject> it = resource.getContents().iterator(); it.hasNext();) {
- Object rootElement = it.next();
- if (rootElement instanceof Diagram) {
- document.setContent(rootElement);
- return;
- }
- }
- }
- throw new RuntimeException(Messages.UMLDocumentProvider_NoDiagramInResourceError);
- } catch (Exception e) {
- CoreException thrownExcp = null;
- if (e instanceof CoreException) {
- thrownExcp = (CoreException) e;
- } else {
- String msg = e.getLocalizedMessage();
- thrownExcp = new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, msg != null ? msg : Messages.UMLDocumentProvider_DiagramLoadingError, e));
- }
- throw thrownExcp;
- }
- } else {
- throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0,
- NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
- null));
- }
- }
-
- /**
- * @generated
- */
- @Override
- public long getModificationStamp(Object element) {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- return computeModificationStamp(info);
- }
- return super.getModificationStamp(element);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isDeleted(Object element) {
- IDiagramDocument document = getDiagramDocument(element);
- if (document != null) {
- Resource diagramResource = document.getDiagram().eResource();
- if (diagramResource != null) {
- IFile file = WorkspaceSynchronizer.getFile(diagramResource);
- return file == null || file.getLocation() == null || !file.getLocation().toFile().exists();
- }
- }
- return super.isDeleted(element);
- }
-
- /**
- * @generated
- */
- public ResourceSetInfo getResourceSetInfo(Object editorInput) {
- return (ResourceSetInfo) super.getElementInfo(editorInput);
- }
-
- /**
- * @generated
- */
- @Override
- protected void disposeElementInfo(Object element, ElementInfo info) {
- if (info instanceof ResourceSetInfo) {
- ResourceSetInfo resourceSetInfo = (ResourceSetInfo) info;
- resourceSetInfo.dispose();
- }
- super.disposeElementInfo(element, info);
- }
-
- /**
- * @generated
- */
- @Override
- protected void doValidateState(Object element, Object computationContext) throws CoreException {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- LinkedList<IFile> files2Validate = new LinkedList<IFile>();
- for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
- Resource nextResource = it.next();
- IFile file = WorkspaceSynchronizer.getFile(nextResource);
- if (file != null && file.isReadOnly()) {
- files2Validate.add(file);
- }
- }
- ResourcesPlugin.getWorkspace().validateEdit(files2Validate.toArray(new IFile[files2Validate.size()]), computationContext);
- }
- super.doValidateState(element, computationContext);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isReadOnly(Object element) {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- if (info.isUpdateCache()) {
- try {
- updateCache(element);
- } catch (CoreException ex) {
- UMLDiagramEditorPlugin.getInstance().logError(Messages.UMLDocumentProvider_isModifiable, ex);
- // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable
- }
- }
- return info.isReadOnly();
- }
- return super.isReadOnly(element);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isModifiable(Object element) {
- if (!isStateValidated(element)) {
- if (element instanceof FileEditorInput || element instanceof URIEditorInput) {
- return true;
- }
- }
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- if (info.isUpdateCache()) {
- try {
- updateCache(element);
- } catch (CoreException ex) {
- UMLDiagramEditorPlugin.getInstance().logError(Messages.UMLDocumentProvider_isModifiable, ex);
- // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable
- }
- }
- return info.isModifiable();
- }
- return super.isModifiable(element);
- }
-
- /**
- * @generated
- */
- protected void updateCache(Object element) throws CoreException {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
- Resource nextResource = it.next();
- IFile file = WorkspaceSynchronizer.getFile(nextResource);
- if (file != null && file.isReadOnly()) {
- info.setReadOnly(true);
- info.setModifiable(false);
- return;
- }
- }
- info.setReadOnly(false);
- info.setModifiable(true);
- return;
- }
- }
-
- /**
- * @generated
- */
- @Override
- protected void doUpdateStateCache(Object element) throws CoreException {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- info.setUpdateCache(true);
- }
- super.doUpdateStateCache(element);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isSynchronized(Object element) {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- return info.isSynchronized();
- }
- return super.isSynchronized(element);
- }
-
- /**
- * @generated
- */
- @Override
- protected ISchedulingRule getResetRule(Object element) {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
- for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
- Resource nextResource = it.next();
- IFile file = WorkspaceSynchronizer.getFile(nextResource);
- if (file != null) {
- rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(file));
- }
- }
- return new MultiRule(rules.toArray(new ISchedulingRule[rules.size()]));
- }
- return null;
- }
-
- /**
- * @generated
- */
- @Override
- protected ISchedulingRule getSaveRule(Object element) {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
- for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
- Resource nextResource = it.next();
- IFile file = WorkspaceSynchronizer.getFile(nextResource);
- if (file != null) {
- rules.add(computeSchedulingRule(file));
- }
- }
- return new MultiRule(rules.toArray(new ISchedulingRule[rules.size()]));
- }
- return null;
- }
-
- /**
- * @generated
- */
- @Override
- protected ISchedulingRule getSynchronizeRule(Object element) {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
- for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
- Resource nextResource = it.next();
- IFile file = WorkspaceSynchronizer.getFile(nextResource);
- if (file != null) {
- rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().refreshRule(file));
- }
- }
- return new MultiRule(rules.toArray(new ISchedulingRule[rules.size()]));
- }
- return null;
- }
-
- /**
- * @generated
- */
- @Override
- protected ISchedulingRule getValidateStateRule(Object element) {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- LinkedList<ISchedulingRule> files = new LinkedList<ISchedulingRule>();
- for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
- Resource nextResource = it.next();
- IFile file = WorkspaceSynchronizer.getFile(nextResource);
- if (file != null) {
- files.add(file);
- }
- }
- return ResourcesPlugin.getWorkspace().getRuleFactory().validateEditRule(files.toArray(new IFile[files.size()]));
- }
- return null;
- }
-
- /**
- * @generated
- */
- private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) {
- if (toCreateOrModify.exists()) {
- return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(toCreateOrModify);
- }
- IResource parent = toCreateOrModify;
- do {
- /*
- * XXX This is a workaround for
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601
- * IResourceRuleFactory.createRule should iterate the hierarchy
- * itself.
- */
- toCreateOrModify = parent;
- parent = toCreateOrModify.getParent();
- } while (parent != null && !parent.exists());
- return ResourcesPlugin.getWorkspace().getRuleFactory().createRule(toCreateOrModify);
- }
-
- /**
- * @generated
- */
- @Override
- protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
- Resource nextResource = it.next();
- handleElementChanged(info, nextResource, monitor);
- }
- return;
- }
- super.doSynchronize(element, monitor);
- }
-
- /**
- * @generated
- */
- @Override
- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
- ResourceSetInfo info = getResourceSetInfo(element);
- if (info != null) {
- if (!overwrite && !info.isSynchronized()) {
- throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, IResourceStatus.OUT_OF_SYNC_LOCAL, Messages.UMLDocumentProvider_UnsynchronizedFileSaveError, null));
- }
- info.stopResourceListening();
- fireElementStateChanging(element);
- try {
- monitor.beginTask(Messages.UMLDocumentProvider_SaveDiagramTask, info.getResourceSet().getResources().size() + 1); // "Saving diagram"
- for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
- Resource nextResource = it.next();
- monitor.setTaskName(NLS.bind(Messages.UMLDocumentProvider_SaveNextResourceTask, nextResource.getURI()));
- if (nextResource.isLoaded() && !info.getEditingDomain().isReadOnly(nextResource)) {
- try {
- nextResource.save(UMLDiagramEditorUtil.getSaveOptions());
- } catch (IOException e) {
- fireElementStateChangeFailed(element);
- throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, EditorStatusCodes.RESOURCE_FAILURE, e.getLocalizedMessage(), null));
- }
- }
- monitor.worked(1);
- }
- monitor.done();
- info.setModificationStamp(computeModificationStamp(info));
- } catch (RuntimeException x) {
- fireElementStateChangeFailed(element);
- throw x;
- } finally {
- info.startResourceListening();
- }
- } else {
- URI newResoruceURI;
- List<IFile> affectedFiles = null;
- if (element instanceof FileEditorInput) {
- IFile newFile = ((FileEditorInput) element).getFile();
- affectedFiles = Collections.singletonList(newFile);
- newResoruceURI = URI.createPlatformResourceURI(newFile.getFullPath().toString(), true);
- } else if (element instanceof URIEditorInput) {
- newResoruceURI = ((URIEditorInput) element).getURI();
- } else {
- fireElementStateChangeFailed(element);
- throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, new Object[] { element,
- "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
- null));
- }
- if (false == document instanceof IDiagramDocument) {
- fireElementStateChangeFailed(element);
- throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, "Incorrect document used: " + document + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", null)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- IDiagramDocument diagramDocument = (IDiagramDocument) document;
- final Resource newResource = diagramDocument.getEditingDomain().getResourceSet().createResource(newResoruceURI);
- final Diagram diagramCopy = EcoreUtil.copy(diagramDocument.getDiagram());
- try {
- new AbstractTransactionalCommand(diagramDocument.getEditingDomain(), NLS.bind(Messages.UMLDocumentProvider_SaveAsOperation, diagramCopy.getName()), affectedFiles) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- newResource.getContents().add(diagramCopy);
- return CommandResult.newOKCommandResult();
- }
- }.execute(monitor, null);
- newResource.save(UMLDiagramEditorUtil.getSaveOptions());
- } catch (ExecutionException e) {
- fireElementStateChangeFailed(element);
- throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null));
- } catch (IOException e) {
- fireElementStateChangeFailed(element);
- throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null));
- }
- newResource.unload();
- }
- }
-
- /**
- * @generated
- */
- protected void handleElementChanged(ResourceSetInfo info, Resource changedResource, IProgressMonitor monitor) {
- IFile file = WorkspaceSynchronizer.getFile(changedResource);
- if (file != null) {
- try {
- file.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- } catch (CoreException ex) {
- UMLDiagramEditorPlugin.getInstance().logError(Messages.UMLDocumentProvider_handleElementContentChanged, ex);
- // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileDocumentProvider_handleElementContentChanged
- }
- }
- changedResource.unload();
- fireElementContentAboutToBeReplaced(info.getEditorInput());
- removeUnchangedElementListeners(info.getEditorInput(), info);
- info.fStatus = null;
- try {
- setDocumentContent(info.fDocument, info.getEditorInput());
- } catch (CoreException e) {
- info.fStatus = e.getStatus();
- }
- if (!info.fCanBeSaved) {
- info.setModificationStamp(computeModificationStamp(info));
- }
- addUnchangedElementListeners(info.getEditorInput(), info);
- fireElementContentReplaced(info.getEditorInput());
- }
-
- /**
- * @generated
- */
- protected void handleElementMoved(IEditorInput input, URI uri) {
- if (input instanceof FileEditorInput) {
- IFile newFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(URI.decode(uri.path())).removeFirstSegments(1));
- fireElementMoved(input, newFile == null ? null : new FileEditorInput(newFile));
- return;
- }
- // TODO: append suffix to the URI! (use diagram as a parameter)
- fireElementMoved(input, new URIEditorInput(uri));
- }
-
- /**
- * @generated
- */
- public IEditorInput createInputWithEditingDomain(IEditorInput editorInput, TransactionalEditingDomain domain) {
- return editorInput;
- }
-
- /**
- * @generated
- */
- public IDiagramDocument getDiagramDocument(Object element) {
- IDocument doc = getDocument(element);
- if (doc instanceof IDiagramDocument) {
- return (IDiagramDocument) doc;
- }
- return null;
- }
-
- /**
- * @generated
- */
- @Override
- protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
- return null;
- }
-
- /**
- * @generated
- */
- protected class ResourceSetInfo extends ElementInfo {
-
- /**
- * @generated
- */
- private long myModificationStamp = IResource.NULL_STAMP;
-
- /**
- * @generated
- */
- private WorkspaceSynchronizer mySynchronizer;
-
- /**
- * @generated
- */
- private LinkedList<Resource> myUnSynchronizedResources = new LinkedList<Resource>();
-
- /**
- * @generated
- */
- private IDiagramDocument myDocument;
-
- /**
- * @generated
- */
- private IEditorInput myEditorInput;
-
- /**
- * @generated
- */
- private boolean myUpdateCache = true;
-
- /**
- * @generated
- */
- private boolean myModifiable = false;
-
- /**
- * @generated
- */
- private boolean myReadOnly = true;
-
- /**
- * @generated
- */
- private ResourceSetModificationListener myResourceSetListener;
-
- /**
- * @generated
- */
- public ResourceSetInfo(IDiagramDocument document, IEditorInput editorInput) {
- super(document);
- myDocument = document;
- myEditorInput = editorInput;
- startResourceListening();
- myResourceSetListener = new ResourceSetModificationListener(this);
- getResourceSet().eAdapters().add(myResourceSetListener);
- }
-
- /**
- * @generated
- */
- public long getModificationStamp() {
- return myModificationStamp;
- }
-
- /**
- * @generated
- */
- public void setModificationStamp(long modificationStamp) {
- myModificationStamp = modificationStamp;
- }
-
- /**
- * @generated
- */
- public TransactionalEditingDomain getEditingDomain() {
- return myDocument.getEditingDomain();
- }
-
- /**
- * @generated
- */
- public ResourceSet getResourceSet() {
- return getEditingDomain().getResourceSet();
- }
-
- /**
- * @generated
- */
- public Iterator<Resource> getLoadedResourcesIterator() {
- return new ArrayList<Resource>(getResourceSet().getResources()).iterator();
- }
-
- /**
- * @generated
- */
- public IEditorInput getEditorInput() {
- return myEditorInput;
- }
-
- /**
- * @generated
- */
- public void dispose() {
- stopResourceListening();
- getResourceSet().eAdapters().remove(myResourceSetListener);
- for (Iterator<Resource> it = getLoadedResourcesIterator(); it.hasNext();) {
- Resource resource = it.next();
- resource.unload();
- }
- getEditingDomain().dispose();
- }
-
- /**
- * @generated
- */
- public boolean isSynchronized() {
- return myUnSynchronizedResources.size() == 0;
- }
-
- /**
- * @generated
- */
- public void setUnSynchronized(Resource resource) {
- myUnSynchronizedResources.add(resource);
- }
-
- /**
- * @generated
- */
- public void setSynchronized(Resource resource) {
- myUnSynchronizedResources.remove(resource);
- }
-
- /**
- * @generated
- */
- public final void stopResourceListening() {
- mySynchronizer.dispose();
- mySynchronizer = null;
- }
-
- /**
- * @generated
- */
- public final void startResourceListening() {
- mySynchronizer = new WorkspaceSynchronizer(getEditingDomain(), new SynchronizerDelegate());
- }
-
- /**
- * @generated
- */
- public boolean isUpdateCache() {
- return myUpdateCache;
- }
-
- /**
- * @generated
- */
- public void setUpdateCache(boolean update) {
- myUpdateCache = update;
- }
-
- /**
- * @generated
- */
- public boolean isModifiable() {
- return myModifiable;
- }
-
- /**
- * @generated
- */
- public void setModifiable(boolean modifiable) {
- myModifiable = modifiable;
- }
-
- /**
- * @generated
- */
- public boolean isReadOnly() {
- return myReadOnly;
- }
-
- /**
- * @generated
- */
- public void setReadOnly(boolean readOnly) {
- myReadOnly = readOnly;
- }
-
- /**
- * @generated
- */
- private class SynchronizerDelegate implements WorkspaceSynchronizer.Delegate {
-
- /**
- * @generated
- */
- public void dispose() {
- }
-
- /**
- * @generated
- */
- public boolean handleResourceChanged(final Resource resource) {
- synchronized (ResourceSetInfo.this) {
- if (ResourceSetInfo.this.fCanBeSaved) {
- ResourceSetInfo.this.setUnSynchronized(resource);
- return true;
- }
- }
- Display.getDefault().asyncExec(new Runnable() {
-
- public void run() {
- handleElementChanged(ResourceSetInfo.this, resource, null);
- }
- });
- return true;
- }
-
- /**
- * @generated
- */
- public boolean handleResourceDeleted(Resource resource) {
- synchronized (ResourceSetInfo.this) {
- if (ResourceSetInfo.this.fCanBeSaved) {
- ResourceSetInfo.this.setUnSynchronized(resource);
- return true;
- }
- }
- Display.getDefault().asyncExec(new Runnable() {
-
- public void run() {
- fireElementDeleted(ResourceSetInfo.this.getEditorInput());
- }
- });
- return true;
- }
-
- /**
- * @generated
- */
- public boolean handleResourceMoved(Resource resource, final URI newURI) {
- synchronized (ResourceSetInfo.this) {
- if (ResourceSetInfo.this.fCanBeSaved) {
- ResourceSetInfo.this.setUnSynchronized(resource);
- return true;
- }
- }
- if (myDocument.getDiagram().eResource() == resource) {
- Display.getDefault().asyncExec(new Runnable() {
-
- public void run() {
- handleElementMoved(ResourceSetInfo.this.getEditorInput(), newURI);
- }
- });
- } else {
- handleResourceDeleted(resource);
- }
- return true;
- }
- }
- }
-
- /**
- * @generated
- */
- private class ResourceSetModificationListener extends EContentAdapter {
-
- /**
- * @generated
- */
- private NotificationFilter myModifiedFilter;
-
- /**
- * @generated
- */
- private ResourceSetInfo myInfo;
-
- /**
- * @generated
- */
- public ResourceSetModificationListener(ResourceSetInfo info) {
- myInfo = info;
- myModifiedFilter = NotificationFilter.createEventTypeFilter(Notification.SET).or(NotificationFilter.createEventTypeFilter(Notification.UNSET)).and(NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__IS_MODIFIED));
- }
-
- /**
- * @generated
- */
- @Override
- public void notifyChanged(Notification notification) {
- if (notification.getNotifier() instanceof ResourceSet) {
- super.notifyChanged(notification);
- }
- if (!notification.isTouch() && myModifiedFilter.matches(notification)) {
- if (notification.getNotifier() instanceof Resource) {
- Resource resource = (Resource) notification.getNotifier();
- if (resource.isLoaded()) {
- boolean modified = false;
- for (Iterator<Resource> it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) {
- Resource nextResource = it.next();
- if (nextResource.isLoaded()) {
- modified = nextResource.isModified();
- }
- }
- boolean dirtyStateChanged = false;
- synchronized (myInfo) {
- if (modified != myInfo.fCanBeSaved) {
- myInfo.fCanBeSaved = modified;
- dirtyStateChanged = true;
- }
- if (!resource.isModified()) {
- myInfo.setSynchronized(resource);
- }
- }
- if (dirtyStateChanged) {
- fireElementDirtyStateChanged(myInfo.getEditorInput(), modified);
- if (!modified) {
- myInfo.setModificationStamp(computeModificationStamp(myInfo));
- }
- }
- }
- }
- }
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import java.io.IOException;
+import java.util.ArrayList;
+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.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.MultiRule;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.transaction.NotificationFilter;
+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.DiagramEditingDomainFactory;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.EditorStatusCodes;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.util.DiagramIOUtil;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * @generated
+ */
+public class UMLDocumentProvider extends AbstractDocumentProvider implements IDiagramDocumentProvider {
+
+ /**
+ * @generated
+ */
+ @Override
+ protected ElementInfo createElementInfo(Object element) throws CoreException {
+ if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) {
+ throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0,
+ NLS.bind(
+ Messages.UMLDocumentProvider_IncorrectInputError,
+ new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
+ null));
+ }
+ IEditorInput editorInput = (IEditorInput) element;
+ IDiagramDocument document = (IDiagramDocument) createDocument(editorInput);
+ ResourceSetInfo info = new ResourceSetInfo(document, editorInput);
+ info.setModificationStamp(computeModificationStamp(info));
+ info.fStatus = null;
+ return info;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IDocument createDocument(Object element) throws CoreException {
+ if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) {
+ throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0,
+ NLS.bind(
+ Messages.UMLDocumentProvider_IncorrectInputError,
+ new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
+ null));
+ }
+ IDocument document = createEmptyDocument();
+ setDocumentContent(document, (IEditorInput) element);
+ setupDocument(element, document);
+ return document;
+ }
+
+ /**
+ * Sets up the given document as it would be provided for the given element. The
+ * content of the document is not changed. This default implementation is empty.
+ * Subclasses may reimplement.
+ *
+ * @param element
+ * the blue-print element
+ * @param document
+ * the document to set up
+ * @generated
+ */
+ protected void setupDocument(Object element, IDocument document) {
+ // for subclasses
+ }
+
+ /**
+ * @generated
+ */
+ private long computeModificationStamp(ResourceSetInfo info) {
+ int result = 0;
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ if (file.getLocation() != null) {
+ result += file.getLocation().toFile().lastModified();
+ } else {
+ result += file.getModificationStamp();
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IDocument createEmptyDocument() {
+ DiagramDocument document = new DiagramDocument();
+ document.setEditingDomain(createEditingDomain());
+ return document;
+ }
+
+ /**
+ * @generated
+ */
+ private TransactionalEditingDomain createEditingDomain() {
+ TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain();
+ editingDomain.setID("org.eclipse.papyrus.uml.diagram.profile.EditingDomain"); //$NON-NLS-1$
+ final NotificationFilter diagramResourceModifiedFilter = NotificationFilter.createNotifierFilter(editingDomain.getResourceSet()).and(NotificationFilter.createEventTypeFilter(Notification.ADD)).and(NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES));
+ editingDomain.getResourceSet().eAdapters().add(new Adapter() {
+
+ private Notifier myTarger;
+
+ public Notifier getTarget() {
+ return myTarger;
+ }
+
+ public boolean isAdapterForType(Object type) {
+ return false;
+ }
+
+ public void notifyChanged(Notification notification) {
+ if (diagramResourceModifiedFilter.matches(notification)) {
+ Object value = notification.getNewValue();
+ if (value instanceof Resource) {
+ ((Resource) value).setTrackingModification(true);
+ }
+ }
+ }
+
+ public void setTarget(Notifier newTarget) {
+ myTarger = newTarget;
+ }
+ });
+ return editingDomain;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setDocumentContent(IDocument document, IEditorInput element) throws CoreException {
+ IDiagramDocument diagramDocument = (IDiagramDocument) document;
+ TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
+ if (element instanceof FileEditorInput) {
+ IStorage storage = ((FileEditorInput) element).getStorage();
+ Diagram diagram = DiagramIOUtil.load(domain, storage, true, getProgressMonitor());
+ document.setContent(diagram);
+ } else if (element instanceof URIEditorInput) {
+ URI uri = ((URIEditorInput) element).getURI();
+ Resource resource = null;
+ try {
+ resource = domain.getResourceSet().getResource(uri.trimFragment(), false);
+ if (resource == null) {
+ resource = domain.getResourceSet().createResource(uri.trimFragment());
+ }
+ if (!resource.isLoaded()) {
+ try {
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ Map<?, ?> options = new HashMap(GMFResourceFactory.getDefaultLoadOptions());
+ // @see 171060
+ // options.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
+ resource.load(options);
+ } catch (IOException e) {
+ resource.unload();
+ throw e;
+ }
+ }
+ if (uri.fragment() != null) {
+ EObject rootElement = resource.getEObject(uri.fragment());
+ if (rootElement instanceof Diagram) {
+ document.setContent((Diagram) rootElement);
+ return;
+ }
+ } else {
+ for (Iterator<EObject> it = resource.getContents().iterator(); it.hasNext();) {
+ Object rootElement = it.next();
+ if (rootElement instanceof Diagram) {
+ document.setContent((Diagram) rootElement);
+ return;
+ }
+ }
+ }
+ throw new RuntimeException(Messages.UMLDocumentProvider_NoDiagramInResourceError);
+ } catch (Exception e) {
+ CoreException thrownExcp = null;
+ if (e instanceof CoreException) {
+ thrownExcp = (CoreException) e;
+ } else {
+ String msg = e.getLocalizedMessage();
+ thrownExcp = new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0,
+ msg != null ? msg : Messages.UMLDocumentProvider_DiagramLoadingError, e));
+ }
+ throw thrownExcp;
+ }
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0,
+ NLS.bind(
+ Messages.UMLDocumentProvider_IncorrectInputError,
+ new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
+ null));
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public long getModificationStamp(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ return computeModificationStamp(info);
+ }
+ return super.getModificationStamp(element);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isDeleted(Object element) {
+ IDiagramDocument document = getDiagramDocument(element);
+ if (document != null) {
+ Resource diagramResource = document.getDiagram().eResource();
+ if (diagramResource != null) {
+ IFile file = WorkspaceSynchronizer.getFile(diagramResource);
+ return file == null || file.getLocation() == null || !file.getLocation().toFile().exists();
+ }
+ }
+ return super.isDeleted(element);
+ }
+
+ /**
+ * @generated
+ */
+ public ResourceSetInfo getResourceSetInfo(Object editorInput) {
+ return (ResourceSetInfo) super.getElementInfo(editorInput);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void disposeElementInfo(Object element, ElementInfo info) {
+ if (info instanceof ResourceSetInfo) {
+ ResourceSetInfo resourceSetInfo = (ResourceSetInfo) info;
+ resourceSetInfo.dispose();
+ }
+ super.disposeElementInfo(element, info);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void doValidateState(Object element, Object computationContext) throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ LinkedList<IFile> files2Validate = new LinkedList<IFile>();
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null && file.isReadOnly()) {
+ files2Validate.add(file);
+ }
+ }
+ ResourcesPlugin.getWorkspace().validateEdit((IFile[]) files2Validate.toArray(new IFile[files2Validate.size()]), computationContext);
+ }
+ super.doValidateState(element, computationContext);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isReadOnly(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ if (info.isUpdateCache()) {
+ try {
+ updateCache(element);
+ } catch (CoreException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError(Messages.UMLDocumentProvider_isModifiable, ex);
+ // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable
+ }
+ }
+ return info.isReadOnly();
+ }
+ return super.isReadOnly(element);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isModifiable(Object element) {
+ if (!isStateValidated(element)) {
+ if (element instanceof FileEditorInput || element instanceof URIEditorInput) {
+ return true;
+ }
+ }
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ if (info.isUpdateCache()) {
+ try {
+ updateCache(element);
+ } catch (CoreException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError(Messages.UMLDocumentProvider_isModifiable, ex);
+ // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable
+ }
+ }
+ return info.isModifiable();
+ }
+ return super.isModifiable(element);
+ }
+
+ /**
+ * @generated
+ */
+ protected void updateCache(Object element) throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null && file.isReadOnly()) {
+ info.setReadOnly(true);
+ info.setModifiable(false);
+ return;
+ }
+ }
+ info.setReadOnly(false);
+ info.setModifiable(true);
+ return;
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void doUpdateStateCache(Object element) throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ info.setUpdateCache(true);
+ }
+ super.doUpdateStateCache(element);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isSynchronized(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ return info.isSynchronized();
+ }
+ return super.isSynchronized(element);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected ISchedulingRule getResetRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(file));
+ }
+ }
+ return new MultiRule((ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()]));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected ISchedulingRule getSaveRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(computeSchedulingRule(file));
+ }
+ }
+ return new MultiRule((ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()]));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected ISchedulingRule getSynchronizeRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().refreshRule(file));
+ }
+ }
+ return new MultiRule((ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()]));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected ISchedulingRule getValidateStateRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ LinkedList<ISchedulingRule> files = new LinkedList<ISchedulingRule>();
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ Resource nextResource = it.next();
+ IFile file = WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ files.add(file);
+ }
+ }
+ return ResourcesPlugin.getWorkspace().getRuleFactory().validateEditRule((IFile[]) files.toArray(new IFile[files.size()]));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) {
+ if (toCreateOrModify.exists())
+ return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(toCreateOrModify);
+ IResource parent = toCreateOrModify;
+ do {
+ /*
+ * XXX This is a workaround for
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601
+ * IResourceRuleFactory.createRule should iterate the hierarchy
+ * itself.
+ */
+ toCreateOrModify = parent;
+ parent = toCreateOrModify.getParent();
+ } while (parent != null && !parent.exists());
+ return ResourcesPlugin.getWorkspace().getRuleFactory().createRule(toCreateOrModify);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ Resource nextResource = it.next();
+ handleElementChanged(info, nextResource, monitor);
+ }
+ return;
+ }
+ super.doSynchronize(element, monitor);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ if (!overwrite && !info.isSynchronized()) {
+ throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID,
+ IResourceStatus.OUT_OF_SYNC_LOCAL,
+ Messages.UMLDocumentProvider_UnsynchronizedFileSaveError,
+ null));
+ }
+ info.stopResourceListening();
+ fireElementStateChanging(element);
+ try {
+ monitor.beginTask(Messages.UMLDocumentProvider_SaveDiagramTask, info.getResourceSet().getResources().size() + 1); //"Saving diagram"
+ for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ Resource nextResource = it.next();
+ monitor.setTaskName(NLS.bind(
+ Messages.UMLDocumentProvider_SaveNextResourceTask,
+ nextResource.getURI()));
+ if (nextResource.isLoaded() && !info.getEditingDomain().isReadOnly(nextResource)) {
+ try {
+ nextResource.save(UMLDiagramEditorUtil.getSaveOptions());
+ } catch (IOException e) {
+ fireElementStateChangeFailed(element);
+ throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, EditorStatusCodes.RESOURCE_FAILURE, e.getLocalizedMessage(), null));
+ }
+ }
+ monitor.worked(1);
+ }
+ monitor.done();
+ info.setModificationStamp(computeModificationStamp(info));
+ } catch (RuntimeException x) {
+ fireElementStateChangeFailed(element);
+ throw x;
+ } finally {
+ info.startResourceListening();
+ }
+ } else {
+ URI newResoruceURI;
+ List<IFile> affectedFiles = null;
+ if (element instanceof FileEditorInput) {
+ IFile newFile = ((FileEditorInput) element).getFile();
+ affectedFiles = Collections.singletonList(newFile);
+ newResoruceURI = URI.createPlatformResourceURI(newFile.getFullPath().toString(), true);
+ } else if (element instanceof URIEditorInput) {
+ newResoruceURI = ((URIEditorInput) element).getURI();
+ } else {
+ fireElementStateChangeFailed(element);
+ throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0,
+ NLS.bind(
+ Messages.UMLDocumentProvider_IncorrectInputError,
+ new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
+ null));
+ }
+ if (false == document instanceof IDiagramDocument) {
+ fireElementStateChangeFailed(element);
+ throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0,
+ "Incorrect document used: " + document + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", null)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ IDiagramDocument diagramDocument = (IDiagramDocument) document;
+ final Resource newResource = diagramDocument.getEditingDomain().getResourceSet().createResource(newResoruceURI);
+ final Diagram diagramCopy = (Diagram) EcoreUtil.copy(diagramDocument.getDiagram());
+ try {
+ new AbstractTransactionalCommand(diagramDocument.getEditingDomain(), NLS.bind(Messages.UMLDocumentProvider_SaveAsOperation, diagramCopy.getName()), affectedFiles) {
+
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ newResource.getContents().add(diagramCopy);
+ return CommandResult.newOKCommandResult();
+ }
+ }.execute(monitor, null);
+ newResource.save(UMLDiagramEditorUtil.getSaveOptions());
+ } catch (ExecutionException e) {
+ fireElementStateChangeFailed(element);
+ throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null));
+ } catch (IOException e) {
+ fireElementStateChangeFailed(element);
+ throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null));
+ }
+ newResource.unload();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleElementChanged(ResourceSetInfo info, Resource changedResource, IProgressMonitor monitor) {
+ IFile file = WorkspaceSynchronizer.getFile(changedResource);
+ if (file != null) {
+ try {
+ file.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ } catch (CoreException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError(Messages.UMLDocumentProvider_handleElementContentChanged, ex);
+ // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileDocumentProvider_handleElementContentChanged
+ }
+ }
+ changedResource.unload();
+ fireElementContentAboutToBeReplaced(info.getEditorInput());
+ removeUnchangedElementListeners(info.getEditorInput(), info);
+ info.fStatus = null;
+ try {
+ setDocumentContent(info.fDocument, info.getEditorInput());
+ } catch (CoreException e) {
+ info.fStatus = e.getStatus();
+ }
+ if (!info.fCanBeSaved) {
+ info.setModificationStamp(computeModificationStamp(info));
+ }
+ addUnchangedElementListeners(info.getEditorInput(), info);
+ fireElementContentReplaced(info.getEditorInput());
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleElementMoved(IEditorInput input, URI uri) {
+ if (input instanceof FileEditorInput) {
+ IFile newFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(URI.decode(uri.path())).removeFirstSegments(1));
+ fireElementMoved(input, newFile == null ? null : new FileEditorInput(newFile));
+ return;
+ }
+ // TODO: append suffix to the URI! (use diagram as a parameter)
+ fireElementMoved(input, new URIEditorInput(uri));
+ }
+
+ /**
+ * @generated
+ */
+ public IEditorInput createInputWithEditingDomain(IEditorInput editorInput, TransactionalEditingDomain domain) {
+ return editorInput;
+ }
+
+ /**
+ * @generated
+ */
+ public IDiagramDocument getDiagramDocument(Object element) {
+ IDocument doc = getDocument(element);
+ if (doc instanceof IDiagramDocument) {
+ return (IDiagramDocument) doc;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected class ResourceSetInfo extends ElementInfo {
+
+ /**
+ * @generated
+ */
+ private long myModificationStamp = IResource.NULL_STAMP;
+
+ /**
+ * @generated
+ */
+ private WorkspaceSynchronizer mySynchronizer;
+
+ /**
+ * @generated
+ */
+ private LinkedList<Resource> myUnSynchronizedResources = new LinkedList<Resource>();
+
+ /**
+ * @generated
+ */
+ private IDiagramDocument myDocument;
+
+ /**
+ * @generated
+ */
+ private IEditorInput myEditorInput;
+
+ /**
+ * @generated
+ */
+ private boolean myUpdateCache = true;
+
+ /**
+ * @generated
+ */
+ private boolean myModifiable = false;
+
+ /**
+ * @generated
+ */
+ private boolean myReadOnly = true;
+
+ /**
+ * @generated
+ */
+ private ResourceSetModificationListener myResourceSetListener;
+
+ /**
+ * @generated
+ */
+ public ResourceSetInfo(IDiagramDocument document, IEditorInput editorInput) {
+ super(document);
+ myDocument = document;
+ myEditorInput = editorInput;
+ startResourceListening();
+ myResourceSetListener = new ResourceSetModificationListener(this);
+ getResourceSet().eAdapters().add(myResourceSetListener);
+ }
+
+ /**
+ * @generated
+ */
+ public long getModificationStamp() {
+ return myModificationStamp;
+ }
+
+ /**
+ * @generated
+ */
+ public void setModificationStamp(long modificationStamp) {
+ myModificationStamp = modificationStamp;
+ }
+
+ /**
+ * @generated
+ */
+ public TransactionalEditingDomain getEditingDomain() {
+ return myDocument.getEditingDomain();
+ }
+
+ /**
+ * @generated
+ */
+ public ResourceSet getResourceSet() {
+ return getEditingDomain().getResourceSet();
+ }
+
+ /**
+ * @generated
+ */
+ public Iterator<Resource> getLoadedResourcesIterator() {
+ return new ArrayList<Resource>(getResourceSet().getResources()).iterator();
+ }
+
+ /**
+ * @generated
+ */
+ public IEditorInput getEditorInput() {
+ return myEditorInput;
+ }
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ stopResourceListening();
+ getResourceSet().eAdapters().remove(myResourceSetListener);
+ for (Iterator<Resource> it = getLoadedResourcesIterator(); it.hasNext();) {
+ Resource resource = it.next();
+ resource.unload();
+ }
+ getEditingDomain().dispose();
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isSynchronized() {
+ return myUnSynchronizedResources.size() == 0;
+ }
+
+ /**
+ * @generated
+ */
+ public void setUnSynchronized(Resource resource) {
+ myUnSynchronizedResources.add(resource);
+ }
+
+ /**
+ * @generated
+ */
+ public void setSynchronized(Resource resource) {
+ myUnSynchronizedResources.remove(resource);
+ }
+
+ /**
+ * @generated
+ */
+ public final void stopResourceListening() {
+ mySynchronizer.dispose();
+ mySynchronizer = null;
+ }
+
+ /**
+ * @generated
+ */
+ public final void startResourceListening() {
+ mySynchronizer = new WorkspaceSynchronizer(getEditingDomain(), new SynchronizerDelegate());
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isUpdateCache() {
+ return myUpdateCache;
+ }
+
+ /**
+ * @generated
+ */
+ public void setUpdateCache(boolean update) {
+ myUpdateCache = update;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isModifiable() {
+ return myModifiable;
+ }
+
+ /**
+ * @generated
+ */
+ public void setModifiable(boolean modifiable) {
+ myModifiable = modifiable;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean isReadOnly() {
+ return myReadOnly;
+ }
+
+ /**
+ * @generated
+ */
+ public void setReadOnly(boolean readOnly) {
+ myReadOnly = readOnly;
+ }
+
+ /**
+ * @generated
+ */
+ private class SynchronizerDelegate implements WorkspaceSynchronizer.Delegate {
+
+ /**
+ * @generated
+ */
+ public void dispose() {
+ }
+
+ /**
+ * @generated
+ */
+ public boolean handleResourceChanged(final Resource resource) {
+ synchronized (ResourceSetInfo.this) {
+ if (ResourceSetInfo.this.fCanBeSaved) {
+ ResourceSetInfo.this.setUnSynchronized(resource);
+ return true;
+ }
+ }
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ handleElementChanged(ResourceSetInfo.this, resource, null);
+ }
+ });
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean handleResourceDeleted(Resource resource) {
+ synchronized (ResourceSetInfo.this) {
+ if (ResourceSetInfo.this.fCanBeSaved) {
+ ResourceSetInfo.this.setUnSynchronized(resource);
+ return true;
+ }
+ }
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ fireElementDeleted(ResourceSetInfo.this.getEditorInput());
+ }
+ });
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean handleResourceMoved(Resource resource, final URI newURI) {
+ synchronized (ResourceSetInfo.this) {
+ if (ResourceSetInfo.this.fCanBeSaved) {
+ ResourceSetInfo.this.setUnSynchronized(resource);
+ return true;
+ }
+ }
+ if (myDocument.getDiagram().eResource() == resource) {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ handleElementMoved(ResourceSetInfo.this.getEditorInput(), newURI);
+ }
+ });
+ } else {
+ handleResourceDeleted(resource);
+ }
+ return true;
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private class ResourceSetModificationListener extends EContentAdapter {
+
+ /**
+ * @generated
+ */
+ private NotificationFilter myModifiedFilter;
+
+ /**
+ * @generated
+ */
+ private ResourceSetInfo myInfo;
+
+ /**
+ * @generated
+ */
+ public ResourceSetModificationListener(ResourceSetInfo info) {
+ myInfo = info;
+ myModifiedFilter = NotificationFilter.createEventTypeFilter(Notification.SET).or(NotificationFilter.createEventTypeFilter(Notification.UNSET)).and(NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__IS_MODIFIED));
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ if (notification.getNotifier() instanceof ResourceSet) {
+ super.notifyChanged(notification);
+ }
+ if (!notification.isTouch() && myModifiedFilter.matches(notification)) {
+ if (notification.getNotifier() instanceof Resource) {
+ Resource resource = (Resource) notification.getNotifier();
+ if (resource.isLoaded()) {
+ boolean modified = false;
+ for (Iterator<Resource> it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) {
+ Resource nextResource = (Resource) it.next();
+ if (nextResource.isLoaded()) {
+ modified = nextResource.isModified();
+ }
+ }
+ boolean dirtyStateChanged = false;
+ synchronized (myInfo) {
+ if (modified != myInfo.fCanBeSaved) {
+ myInfo.fCanBeSaved = modified;
+ dirtyStateChanged = true;
+ }
+ if (!resource.isModified()) {
+ myInfo.setSynchronized(resource);
+ }
+ }
+ if (dirtyStateChanged) {
+ fireElementDirtyStateChanged(myInfo.getEditorInput(), modified);
+ if (!modified) {
+ myInfo.setModificationStamp(computeModificationStamp(myInfo));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLInitDiagramFileAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLInitDiagramFileAction.java
index f23807e4c23..4667e8ec1d7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLInitDiagramFileAction.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLInitDiagramFileAction.java
@@ -1,97 +1,105 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.WrappedException;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * @generated
- */
-public class UMLInitDiagramFileAction implements IObjectActionDelegate {
-
- /**
- * @generated
- */
- private IWorkbenchPart targetPart;
-
- /**
- * @generated
- */
- private URI domainModelURI;
-
- /**
- * @generated
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- this.targetPart = targetPart;
- }
-
- /**
- * @generated
- */
- public void selectionChanged(IAction action, ISelection selection) {
- domainModelURI = null;
- action.setEnabled(false);
- if (selection instanceof IStructuredSelection == false || selection.isEmpty()) {
- return;
- }
- IFile file = (IFile) ((IStructuredSelection) selection).getFirstElement();
- domainModelURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
- action.setEnabled(true);
- }
-
- /**
- * @generated
- */
- private Shell getShell() {
- return targetPart.getSite().getShell();
- }
-
- /**
- * @generated
- */
- public void run(IAction action) {
- TransactionalEditingDomain editingDomain = WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain();
- ResourceSet resourceSet = editingDomain.getResourceSet();
- EObject diagramRoot = null;
- try {
- Resource resource = resourceSet.getResource(domainModelURI, true);
- diagramRoot = resource.getContents().get(0);
- } catch (WrappedException ex) {
- UMLDiagramEditorPlugin.getInstance().logError("Unable to load resource: " + domainModelURI, ex); //$NON-NLS-1$
- }
- if (diagramRoot == null) {
- MessageDialog.openError(getShell(), Messages.InitDiagramFile_ResourceErrorDialogTitle, Messages.InitDiagramFile_ResourceErrorDialogMessage);
- return;
- }
- Wizard wizard = new UMLNewDiagramFileWizard(domainModelURI, diagramRoot, editingDomain);
- wizard.setWindowTitle(NLS.bind(Messages.InitDiagramFile_WizardTitle, ProfileDiagramEditPart.MODEL_ID));
- UMLDiagramEditorUtil.runWizard(getShell(), wizard, "InitDiagramFile"); //$NON-NLS-1$
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
+import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @generated
+ */
+public class UMLInitDiagramFileAction implements IObjectActionDelegate {
+
+ /**
+ * @generated
+ */
+ private IWorkbenchPart targetPart;
+
+ /**
+ * @generated
+ */
+ private URI domainModelURI;
+
+ /**
+ * @generated
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ this.targetPart = targetPart;
+ }
+
+ /**
+ * @generated
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ domainModelURI = null;
+ action.setEnabled(false);
+ if (selection instanceof IStructuredSelection == false || selection.isEmpty()) {
+ return;
+ }
+ IFile file =
+ (IFile) ((IStructuredSelection) selection).getFirstElement();
+ domainModelURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+ action.setEnabled(true);
+ }
+
+ /**
+ * @generated
+ */
+ private Shell getShell() {
+ return targetPart.getSite().getShell();
+ }
+
+ /**
+ * @generated
+ */
+ public void run(IAction action) {
+ TransactionalEditingDomain editingDomain =
+ GMFEditingDomainFactory.INSTANCE.createEditingDomain();
+ ResourceSet resourceSet = editingDomain.getResourceSet();
+ EObject diagramRoot = null;
+ try {
+ Resource resource = resourceSet.getResource(domainModelURI, true);
+ diagramRoot = (EObject) resource.getContents().get(0);
+ } catch (WrappedException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Unable to load resource: " + domainModelURI, ex); //$NON-NLS-1$
+ }
+ if (diagramRoot == null) {
+ MessageDialog.openError(getShell(),
+ Messages.InitDiagramFile_ResourceErrorDialogTitle,
+ Messages.InitDiagramFile_ResourceErrorDialogMessage);
+ return;
+ }
+ Wizard wizard = new UMLNewDiagramFileWizard(domainModelURI, diagramRoot, editingDomain);
+ wizard.setWindowTitle(NLS.bind(
+ Messages.InitDiagramFile_WizardTitle,
+ ProfileDiagramEditPart.MODEL_ID));
+ UMLDiagramEditorUtil.runWizard(getShell(), wizard, "InitDiagramFile"); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLNewDiagramFileWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLNewDiagramFileWizard.java
index 5b53f53347e..6ee80877de9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLNewDiagramFileWizard.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLNewDiagramFileWizard.java
@@ -1,175 +1,191 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import java.io.IOException;
-import java.util.LinkedList;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.OperationHistoryFactory;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation;
-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.Diagram;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-
-/**
- * @generated
- */
-public class UMLNewDiagramFileWizard extends Wizard {
-
- /**
- * @generated
- */
- private WizardNewFileCreationPage myFileCreationPage;
-
- /**
- * @generated
- */
- private ModelElementSelectionPage diagramRootElementSelectionPage;
-
- /**
- * @generated
- */
- private TransactionalEditingDomain myEditingDomain;
-
- /**
- * @generated
- */
- public UMLNewDiagramFileWizard(URI domainModelURI, EObject diagramRoot, TransactionalEditingDomain editingDomain) {
- assert domainModelURI != null : "Domain model uri must be specified"; //$NON-NLS-1$
- assert diagramRoot != null : "Doagram root element must be specified"; //$NON-NLS-1$
- assert editingDomain != null : "Editing domain must be specified"; //$NON-NLS-1$
- myFileCreationPage = new WizardNewFileCreationPage(Messages.UMLNewDiagramFileWizard_CreationPageName, StructuredSelection.EMPTY);
- myFileCreationPage.setTitle(Messages.UMLNewDiagramFileWizard_CreationPageTitle);
- myFileCreationPage.setDescription(NLS.bind(Messages.UMLNewDiagramFileWizard_CreationPageDescription, ProfileDiagramEditPart.MODEL_ID));
- IPath filePath;
- String fileName = URI.decode(domainModelURI.trimFileExtension().lastSegment());
- if (domainModelURI.isPlatformResource()) {
- filePath = new Path(domainModelURI.trimSegments(1).toPlatformString(true));
- } else if (domainModelURI.isFile()) {
- filePath = new Path(domainModelURI.trimSegments(1).toFileString());
- } else {
- // TODO : use some default path
- throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$
- }
- myFileCreationPage.setContainerFullPath(filePath);
- myFileCreationPage.setFileName(UMLDiagramEditorUtil.getUniqueFileName(filePath, fileName, "PapyrusUMLProfile_diagram")); //$NON-NLS-1$
- diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(Messages.UMLNewDiagramFileWizard_RootSelectionPageName);
- diagramRootElementSelectionPage.setTitle(Messages.UMLNewDiagramFileWizard_RootSelectionPageTitle);
- diagramRootElementSelectionPage.setDescription(Messages.UMLNewDiagramFileWizard_RootSelectionPageDescription);
- diagramRootElementSelectionPage.setModelElement(diagramRoot);
- myEditingDomain = editingDomain;
- }
-
- /**
- * @generated
- */
- @Override
- public void addPages() {
- addPage(myFileCreationPage);
- addPage(diagramRootElementSelectionPage);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean performFinish() {
- LinkedList<IFile> affectedFiles = new LinkedList<IFile>();
- IFile diagramFile = myFileCreationPage.createNewFile();
- UMLDiagramEditorUtil.setCharset(diagramFile);
- affectedFiles.add(diagramFile);
- URI diagramModelURI = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
- ResourceSet resourceSet = myEditingDomain.getResourceSet();
- final Resource diagramResource = resourceSet.createResource(diagramModelURI);
- AbstractTransactionalCommand command = new AbstractTransactionalCommand(myEditingDomain, Messages.UMLNewDiagramFileWizard_InitDiagramCommand, affectedFiles) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- int diagramVID = UMLVisualIDRegistry.getDiagramVisualID(diagramRootElementSelectionPage.getModelElement());
- if (diagramVID != ProfileDiagramEditPart.VISUAL_ID) {
- return CommandResult.newErrorCommandResult(Messages.UMLNewDiagramFileWizard_IncorrectRootError);
- }
- Diagram diagram = ViewService.createDiagram(diagramRootElementSelectionPage.getModelElement(), ProfileDiagramEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
- diagramResource.getContents().add(diagram);
- new UMLDiagramContentInitializer().initDiagramContent(diagram);
- return CommandResult.newOKCommandResult();
- }
- };
- try {
- OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null);
- diagramResource.save(UMLDiagramEditorUtil.getSaveOptions());
- UMLDiagramEditorUtil.openDiagram(diagramResource);
- } catch (ExecutionException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e); //$NON-NLS-1$
- } catch (IOException ex) {
- UMLDiagramEditorPlugin.getInstance().logError("Save operation failed for: " + diagramModelURI, ex); //$NON-NLS-1$
- } catch (PartInitException ex) {
- UMLDiagramEditorPlugin.getInstance().logError("Unable to open editor", ex); //$NON-NLS-1$
- }
- return true;
- }
-
- /**
- * @generated
- */
- private static class DiagramRootElementSelectionPage extends ModelElementSelectionPage {
-
- /**
- * @generated
- */
- protected DiagramRootElementSelectionPage(String pageName) {
- super(pageName);
- }
-
- /**
- * @generated
- */
- @Override
- protected String getSelectionTitle() {
- return Messages.UMLNewDiagramFileWizard_RootSelectionPageSelectionTitle;
- }
-
- /**
- * @generated
- */
- @Override
- protected boolean validatePage() {
- if (getModelElement() == null) {
- setErrorMessage(Messages.UMLNewDiagramFileWizard_RootSelectionPageNoSelectionMessage);
- return false;
- }
- boolean result = ViewService.getInstance().provides(new CreateDiagramViewOperation(new EObjectAdapter(getModelElement()), ProfileDiagramEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT));
- setErrorMessage(result ? null : Messages.UMLNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage);
- return result;
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import java.io.IOException;
+import java.util.LinkedList;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation;
+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.Diagram;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+/**
+ * @generated
+ */
+public class UMLNewDiagramFileWizard extends Wizard {
+
+ /**
+ * @generated
+ */
+ private WizardNewFileCreationPage myFileCreationPage;
+
+ /**
+ * @generated
+ */
+ private ModelElementSelectionPage diagramRootElementSelectionPage;
+
+ /**
+ * @generated
+ */
+ private TransactionalEditingDomain myEditingDomain;
+
+ /**
+ * @generated
+ */
+ public UMLNewDiagramFileWizard(URI domainModelURI, EObject diagramRoot, TransactionalEditingDomain editingDomain) {
+ assert domainModelURI != null : "Domain model uri must be specified"; //$NON-NLS-1$
+ assert diagramRoot != null : "Doagram root element must be specified"; //$NON-NLS-1$
+ assert editingDomain != null : "Editing domain must be specified"; //$NON-NLS-1$
+ myFileCreationPage = new WizardNewFileCreationPage
+ (Messages.UMLNewDiagramFileWizard_CreationPageName, StructuredSelection.EMPTY);
+ myFileCreationPage.setTitle(Messages.UMLNewDiagramFileWizard_CreationPageTitle);
+ myFileCreationPage.setDescription(NLS.bind(
+ Messages.UMLNewDiagramFileWizard_CreationPageDescription,
+ ProfileDiagramEditPart.MODEL_ID));
+ IPath filePath;
+ String fileName = URI.decode(domainModelURI.trimFileExtension().lastSegment());
+ if (domainModelURI.isPlatformResource()) {
+ filePath = new Path(domainModelURI.trimSegments(1).toPlatformString(true));
+ } else if (domainModelURI.isFile()) {
+ filePath = new Path(domainModelURI.trimSegments(1).toFileString());
+ } else {
+ // TODO : use some default path
+ throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$
+ }
+ myFileCreationPage.setContainerFullPath(filePath);
+ myFileCreationPage.setFileName(UMLDiagramEditorUtil.getUniqueFileName(
+ filePath, fileName, "PapyrusUMLProfile_diagram")); //$NON-NLS-1$
+ diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(Messages.UMLNewDiagramFileWizard_RootSelectionPageName);
+ diagramRootElementSelectionPage.setTitle(Messages.UMLNewDiagramFileWizard_RootSelectionPageTitle);
+ diagramRootElementSelectionPage.setDescription(Messages.UMLNewDiagramFileWizard_RootSelectionPageDescription);
+ diagramRootElementSelectionPage.setModelElement(diagramRoot);
+ myEditingDomain = editingDomain;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void addPages() {
+ addPage(myFileCreationPage);
+ addPage(diagramRootElementSelectionPage);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean performFinish() {
+ LinkedList<IFile> affectedFiles = new LinkedList<IFile>();
+ IFile diagramFile = myFileCreationPage.createNewFile();
+ UMLDiagramEditorUtil.setCharset(diagramFile);
+ affectedFiles.add(diagramFile);
+ URI diagramModelURI = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
+ ResourceSet resourceSet = myEditingDomain.getResourceSet();
+ final Resource diagramResource = resourceSet.createResource(diagramModelURI);
+ AbstractTransactionalCommand command =
+ new AbstractTransactionalCommand(
+ myEditingDomain, Messages.UMLNewDiagramFileWizard_InitDiagramCommand, affectedFiles) {
+
+ protected CommandResult doExecuteWithResult(
+ IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ int diagramVID = UMLVisualIDRegistry.getDiagramVisualID(diagramRootElementSelectionPage.getModelElement());
+ if (diagramVID != ProfileDiagramEditPart.VISUAL_ID) {
+ return CommandResult.newErrorCommandResult(
+ Messages.UMLNewDiagramFileWizard_IncorrectRootError);
+ }
+ Diagram diagram =
+ ViewService.createDiagram(
+ diagramRootElementSelectionPage.getModelElement(), ProfileDiagramEditPart.MODEL_ID,
+ UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
+ diagramResource.getContents().add(diagram);
+ new UMLDiagramContentInitializer().initDiagramContent(diagram);
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ try {
+ OperationHistoryFactory.getOperationHistory().execute(
+ command, new NullProgressMonitor(), null);
+ diagramResource.save(UMLDiagramEditorUtil.getSaveOptions());
+ UMLDiagramEditorUtil.openDiagram(diagramResource);
+ } catch (ExecutionException e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e); //$NON-NLS-1$
+ } catch (IOException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError(
+ "Save operation failed for: " + diagramModelURI, ex); //$NON-NLS-1$
+ } catch (PartInitException ex) {
+ UMLDiagramEditorPlugin.getInstance().logError("Unable to open editor", ex); //$NON-NLS-1$
+ }
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ private static class DiagramRootElementSelectionPage extends ModelElementSelectionPage {
+
+ /**
+ * @generated
+ */
+ protected DiagramRootElementSelectionPage(String pageName) {
+ super(pageName);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getSelectionTitle() {
+ return Messages.UMLNewDiagramFileWizard_RootSelectionPageSelectionTitle;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected boolean validatePage() {
+ if (getModelElement() == null) {
+ setErrorMessage(Messages.UMLNewDiagramFileWizard_RootSelectionPageNoSelectionMessage);
+ return false;
+ }
+ boolean result = ViewService.getInstance().provides(
+ new CreateDiagramViewOperation(
+ new EObjectAdapter(getModelElement()),
+ ProfileDiagramEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT));
+ setErrorMessage(result ? null : Messages.UMLNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage);
+ return result;
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLVisualIDRegistry.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLVisualIDRegistry.java
index 500906d13c2..f699303cd97 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLVisualIDRegistry.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLVisualIDRegistry.java
@@ -1,1191 +1,1191 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.tooling.runtime.structure.DiagramStructure;
-import org.eclipse.papyrus.uml.diagram.common.util.Util;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.*;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * This registry is used to determine which type of visual object should be
- * created for the corresponding Diagram, Node, ChildNode or Link represented
- * by a domain model object.
- *
- * @generated
- */
-public class UMLVisualIDRegistry {
-
- /**
- * @generated
- */
- private static final String DEBUG_KEY = "org.eclipse.papyrus.uml.diagram.profile/debug/visualID"; //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static int getVisualID(View view) {
- if (view instanceof Diagram) {
- if (ProfileDiagramEditPart.MODEL_ID.equals(view.getType())) {
- return ProfileDiagramEditPart.VISUAL_ID;
- } else {
- return -1;
- }
- }
- return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getVisualID(view.getType());
- }
-
- /**
- * @generated
- */
- public static String getModelID(View view) {
- View diagram = view.getDiagram();
- while (view != diagram) {
- EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
- if (annotation != null) {
- return annotation.getDetails().get("modelID"); //$NON-NLS-1$
- }
- view = (View) view.eContainer();
- }
- return diagram != null ? diagram.getType() : null;
- }
-
- /**
- * @generated
- */
- public static int getVisualID(String type) {
- try {
- return Integer.parseInt(type);
- } catch (NumberFormatException e) {
- if (Boolean.TRUE.toString().equalsIgnoreCase(Platform.getDebugOption(DEBUG_KEY))) {
- UMLDiagramEditorPlugin.getInstance().logError("Unable to parse view type as a visualID number: " + type);
- }
- }
- return -1;
- }
-
- /**
- * @generated
- */
- public static String getType(int visualID) {
- return Integer.toString(visualID);
- }
-
- /**
- * @generated
- */
- public static int getDiagramVisualID(EObject domainElement) {
- if (domainElement == null) {
- return -1;
- }
- return 1000;
- }
-
- /**
- * @generated NOT
- * we manually test if it's a class or a metaclass
- */
- public static int getNodeVisualID(View containerView, EObject domainElement) {
- if (domainElement == null) {
- return -1;
- }
- String containerModelID = org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getModelID(containerView);
- if (!ProfileDiagramEditPart.MODEL_ID.equals(containerModelID)) {
- return -1;
- }
- int containerVisualID;
- if (ProfileDiagramEditPart.MODEL_ID.equals(containerModelID)) {
- containerVisualID = org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getVisualID(containerView);
- } else {
- if (containerView instanceof Diagram) {
- containerVisualID = ProfileDiagramEditPart.VISUAL_ID;
- } else {
- return -1;
- }
- }
- switch (containerVisualID) {
- case ProfileDiagramEditPart.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getDependency().isSuperTypeOf(domainElement.eClass())) {
- return DependencyNodeEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getAssociation().isSuperTypeOf(domainElement.eClass())) {
- return AssociationNodeEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getStereotype().isSuperTypeOf(domainElement.eClass())) {
- return StereotypeEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
- if (domainElement instanceof Type) {
- if (Util.isMetaclass((Type) domainElement)) {
- return MetaclassEditPart.VISUAL_ID;
- }
- }
- return ClassEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
- return CommentEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
- return ConstraintEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
- return ModelEditPartTN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
- return ProfileEditPartTN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
- return PackageEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
- return EnumerationEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
- return PrimitiveTypeEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
- return DataTypeEditPart.VISUAL_ID;
- }
- if (NotationPackage.eINSTANCE.getDiagram().isSuperTypeOf(domainElement.eClass())) {
- return ShortCutDiagramEditPart.VISUAL_ID;
- }
- break;
- case PackageEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
- return PackageEditPartCN.VISUAL_ID;
- }
- break;
- case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
- return CommentEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
- return ModelEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
- return ProfileEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
- return PackageEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
- return ConstraintEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
- return EnumerationEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
- return PrimitiveTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
- return DataTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getStereotype().isSuperTypeOf(domainElement.eClass())) {
- return StereotypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
- return ClassEditPartCN.VISUAL_ID;
- }
- break;
- case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
- return CommentEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
- return ModelEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
- return ProfileEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
- return PackageEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
- return ConstraintEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
- return EnumerationEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
- return PrimitiveTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
- return DataTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getStereotype().isSuperTypeOf(domainElement.eClass())) {
- return StereotypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
- return ClassEditPartCN.VISUAL_ID;
- }
- break;
- case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getStereotype().isSuperTypeOf(domainElement.eClass())) {
- return StereotypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
- return ModelEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
- return ProfileEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
- return PackageEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
- return ConstraintEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
- return EnumerationEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
- return PrimitiveTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
- return DataTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
- return CommentEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
- if (domainElement instanceof Type) {
- if (Util.isMetaclass((Type) domainElement)) {
- return MetaclassEditPartCN.VISUAL_ID;
- }
- }
- return ClassEditPartCN.VISUAL_ID;
- }
- break;
- case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getStereotype().isSuperTypeOf(domainElement.eClass())) {
- return StereotypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
- return ModelEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
- return ProfileEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
- return PackageEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
- return ConstraintEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
- return EnumerationEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
- return PrimitiveTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
- return DataTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
- return CommentEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
- if (domainElement instanceof Type) {
- if (Util.isMetaclass((Type) domainElement)) {
- return MetaclassEditPartCN.VISUAL_ID;
- }
- }
- return ClassEditPartCN.VISUAL_ID;
- }
- break;
- case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
- return ClassPropertyEditPart.VISUAL_ID;
- }
- break;
- case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
- return ClassPropertyEditPart.VISUAL_ID;
- }
- break;
- case StereotypeOperationCompartmentEditPart.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
- return ClassOperationEditPart.VISUAL_ID;
- }
- break;
- case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
- return ClassOperationEditPart.VISUAL_ID;
- }
- break;
- case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
- return CommentEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
- return ModelEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
- return ProfileEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
- return PackageEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
- return ConstraintEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
- return EnumerationEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
- return PrimitiveTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
- return DataTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
- return ClassEditPartCN.VISUAL_ID;
- }
- break;
- case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
- return CommentEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
- return ModelEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
- return ProfileEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
- return PackageEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
- return ConstraintEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
- return EnumerationEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
- return PrimitiveTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
- return DataTypeEditPartCN.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
- return ClassEditPartCN.VISUAL_ID;
- }
- break;
- case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getEnumerationLiteral().isSuperTypeOf(domainElement.eClass())) {
- return EnumerationLiteralEditPart.VISUAL_ID;
- }
- break;
- case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getEnumerationLiteral().isSuperTypeOf(domainElement.eClass())) {
- return EnumerationLiteralEditPart.VISUAL_ID;
- }
- break;
- case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
- return DataTypePropertyEditPart.VISUAL_ID;
- }
- break;
- case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
- return DataTypePropertyEditPart.VISUAL_ID;
- }
- break;
- case DataTypeOperationCompartmentEditPart.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
- return DataTypeOperationEditPart.VISUAL_ID;
- }
- break;
- case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
- return DataTypeOperationEditPart.VISUAL_ID;
- }
- break;
- case ClassAttributeCompartmentEditPart.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
- return ClassPropertyEditPart.VISUAL_ID;
- }
- break;
- case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
- return ClassPropertyEditPart.VISUAL_ID;
- }
- break;
- case ClassOperationCompartmentEditPart.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
- return ClassOperationEditPart.VISUAL_ID;
- }
- break;
- case ClassOperationCompartmentEditPartCN.VISUAL_ID:
- if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
- return ClassOperationEditPart.VISUAL_ID;
- }
- break;
- }
- return -1;
- }
-
- /**
- * @generated
- */
- public static boolean canCreateNode(View containerView, int nodeVisualID) {
- String containerModelID = org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getModelID(containerView);
- if (!ProfileDiagramEditPart.MODEL_ID.equals(containerModelID)) {
- return false;
- }
- int containerVisualID;
- if (ProfileDiagramEditPart.MODEL_ID.equals(containerModelID)) {
- containerVisualID = org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getVisualID(containerView);
- } else {
- if (containerView instanceof Diagram) {
- containerVisualID = ProfileDiagramEditPart.VISUAL_ID;
- } else {
- return false;
- }
- }
- switch (containerVisualID) {
- case ProfileDiagramEditPart.VISUAL_ID:
- if (DependencyNodeEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (AssociationNodeEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (StereotypeEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (MetaclassEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (CommentEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ConstraintEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ModelEditPartTN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ProfileEditPartTN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PackageEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (EnumerationEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PrimitiveTypeEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ShortCutDiagramEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case DependencyNodeEditPart.VISUAL_ID:
- if (MultiDependencyLabelEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case StereotypeEditPart.VISUAL_ID:
- if (StereotypeNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (StereotypeAttributeCompartmentEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (StereotypeOperationCompartmentEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ClassEditPart.VISUAL_ID:
- if (ClassNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassOperationCompartmentEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassAttributeCompartmentEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case MetaclassEditPart.VISUAL_ID:
- if (MetaclassNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case CommentEditPart.VISUAL_ID:
- if (CommentBodyEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ConstraintEditPart.VISUAL_ID:
- if (ConstraintNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ConstraintBodyEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ModelEditPartTN.VISUAL_ID:
- if (ModelNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ModelPackageableElementCompartmentEditPartTN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ProfileEditPartTN.VISUAL_ID:
- if (ProfileNameEditPartTN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case PackageEditPart.VISUAL_ID:
- if (PackageNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PackagePackageableElementCompartmentEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case EnumerationEditPart.VISUAL_ID:
- if (EnumerationNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case PrimitiveTypeEditPart.VISUAL_ID:
- if (PrimitiveTypeNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case DataTypeEditPart.VISUAL_ID:
- if (DataTypeNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeAttributeCompartmentEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeOperationCompartmentEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ShortCutDiagramEditPart.VISUAL_ID:
- if (DiagramNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case PrimitiveTypeEditPartCN.VISUAL_ID:
- if (PrimitiveTypeNameEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case StereotypeEditPartCN.VISUAL_ID:
- if (StereotypeNameEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (StereotypeAttributeCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (StereotypeOperationCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ClassEditPartCN.VISUAL_ID:
- if (ClassNameEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassAttributeCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassOperationCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case MetaclassEditPartCN.VISUAL_ID:
- if (MetaclassNameEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case CommentEditPartCN.VISUAL_ID:
- if (CommentBodyEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ModelEditPartCN.VISUAL_ID:
- if (ModelNameEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ModelPackageableElementCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ProfileEditPartCN.VISUAL_ID:
- if (ProfileNameEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case PackageEditPartCN.VISUAL_ID:
- if (PackageNameEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PackagePackageableElementCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ConstraintEditPartCN.VISUAL_ID:
- if (ConstraintNameEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ConstraintBodyEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case EnumerationEditPartCN.VISUAL_ID:
- if (EnumerationNameEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case DataTypeEditPartCN.VISUAL_ID:
- if (DataTypeNameEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeAttributeCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeOperationCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
- if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (StereotypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
- if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (StereotypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
- if (StereotypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (MetaclassEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
- if (StereotypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (MetaclassEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
- if (ClassPropertyEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
- if (ClassPropertyEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case StereotypeOperationCompartmentEditPart.VISUAL_ID:
- if (ClassOperationEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
- if (ClassOperationEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
- if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
- if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
- if (EnumerationLiteralEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
- if (EnumerationLiteralEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
- if (DataTypePropertyEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
- if (DataTypePropertyEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case DataTypeOperationCompartmentEditPart.VISUAL_ID:
- if (DataTypeOperationEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
- if (DataTypeOperationEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ClassAttributeCompartmentEditPart.VISUAL_ID:
- if (ClassPropertyEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
- if (ClassPropertyEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ClassOperationCompartmentEditPart.VISUAL_ID:
- if (ClassOperationEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ClassOperationCompartmentEditPartCN.VISUAL_ID:
- if (ClassOperationEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case AssociationEditPart.VISUAL_ID:
- if (AssociationAppliedStereotypeEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (AssociationNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (AssociationRoleTargetEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (AssociationRoleSourceEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (AssociationMultiplicitySourceEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (AssociationMultiplicityTargetEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case AssociationBranchEditPart.VISUAL_ID:
- if (AssociationBranchRoleEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (AssociationBranchMultiplicityEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case GeneralizationEditPart.VISUAL_ID:
- if (GeneralizationAppliedStereotypeEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case DependencyEditPart.VISUAL_ID:
- if (DependencyNameEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (DependencyAppliedStereotypeEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case ElementImportEditPart.VISUAL_ID:
- if (ElementImportAliasEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- if (AppliedStereotypeElementImportEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- case PackageImportEditPart.VISUAL_ID:
- if (PackageImportAppliedStereotypeEditPart.VISUAL_ID == nodeVisualID) {
- return true;
- }
- break;
- }
- return false;
- }
-
- /**
- * @generated
- */
- public static int getLinkWithClassVisualID(EObject domainElement) {
- if (domainElement == null) {
- return -1;
- }
- if (UMLPackage.eINSTANCE.getExtension().isSuperTypeOf(domainElement.eClass())) {
- return ExtensionEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getAssociation().isSuperTypeOf(domainElement.eClass())) {
- return AssociationEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getProfileApplication().isSuperTypeOf(domainElement.eClass())) {
- return ProfileApplicationEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getAssociation().isSuperTypeOf(domainElement.eClass())) {
- return AssociationBranchEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getGeneralization().isSuperTypeOf(domainElement.eClass())) {
- return GeneralizationEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getDependency().isSuperTypeOf(domainElement.eClass())) {
- return DependencyEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getDependency().isSuperTypeOf(domainElement.eClass())) {
- return DependencyBranchEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getElementImport().isSuperTypeOf(domainElement.eClass())) {
- return ElementImportEditPart.VISUAL_ID;
- }
- if (UMLPackage.eINSTANCE.getPackageImport().isSuperTypeOf(domainElement.eClass())) {
- return PackageImportEditPart.VISUAL_ID;
- }
- return -1;
- }
-
- /**
- * User can change implementation of this method to handle some specific
- * situations not covered by default logic.
- *
- * @generated
- */
- private static boolean isDiagram(Profile element) {
- return true;
- }
-
- /**
- * @generated
- */
- public static boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate) {
- if (candidate == -1) {
- // unrecognized id is always bad
- return false;
- }
- int basic = getNodeVisualID(containerView, domainElement);
- return basic == candidate;
- }
-
- /**
- * @generated
- */
- public static boolean isCompartmentVisualID(int visualID) {
- switch (visualID) {
- case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
- case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
- case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
- case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
- case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
- case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
- case StereotypeOperationCompartmentEditPart.VISUAL_ID:
- case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
- case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
- case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
- case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
- case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
- case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
- case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
- case DataTypeOperationCompartmentEditPart.VISUAL_ID:
- case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
- case ClassAttributeCompartmentEditPart.VISUAL_ID:
- case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
- case ClassOperationCompartmentEditPart.VISUAL_ID:
- case ClassOperationCompartmentEditPartCN.VISUAL_ID:
- return true;
- default:
- break;
- }
- return false;
- }
-
- /**
- * @generated
- */
- public static boolean isSemanticLeafVisualID(int visualID) {
- switch (visualID) {
- case ProfileDiagramEditPart.VISUAL_ID:
- return false;
- case CommentEditPart.VISUAL_ID:
- case CommentEditPartCN.VISUAL_ID:
- case ConstraintEditPart.VISUAL_ID:
- case ConstraintEditPartCN.VISUAL_ID:
- case MetaclassEditPart.VISUAL_ID:
- case EnumerationLiteralEditPart.VISUAL_ID:
- case PrimitiveTypeEditPart.VISUAL_ID:
- case DependencyNodeEditPart.VISUAL_ID:
- case AssociationNodeEditPart.VISUAL_ID:
- case ShortCutDiagramEditPart.VISUAL_ID:
- case ClassPropertyEditPart.VISUAL_ID:
- case DataTypePropertyEditPart.VISUAL_ID:
- case DataTypeOperationEditPart.VISUAL_ID:
- case ClassOperationEditPart.VISUAL_ID:
- case PrimitiveTypeEditPartCN.VISUAL_ID:
- case MetaclassEditPartCN.VISUAL_ID:
- return true;
- default:
- break;
- }
- return false;
- }
-
- /**
- * @generated
- */
- public static final DiagramStructure TYPED_INSTANCE = new DiagramStructure() {
-
- /**
- * @generated
- */
- @Override
- public int getVisualID(View view) {
- return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getVisualID(view);
- }
-
- /**
- * @generated
- */
- @Override
- public String getModelID(View view) {
- return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getModelID(view);
- }
-
- /**
- * @generated
- */
- @Override
- public int getNodeVisualID(View containerView, EObject domainElement) {
- return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getNodeVisualID(containerView, domainElement);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate) {
- return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.checkNodeVisualID(containerView, domainElement, candidate);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isCompartmentVisualID(int visualID) {
- return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.isCompartmentVisualID(visualID);
- }
-
- /**
- * @generated
- */
- @Override
- public boolean isSemanticLeafVisualID(int visualID) {
- return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.isSemanticLeafVisualID(visualID);
- }
- };
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.structure.DiagramStructure;
+import org.eclipse.papyrus.uml.diagram.common.util.Util;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.*;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * This registry is used to determine which type of visual object should be
+ * created for the corresponding Diagram, Node, ChildNode or Link represented
+ * by a domain model object.
+ *
+ * @generated
+ */
+public class UMLVisualIDRegistry {
+
+ /**
+ * @generated
+ */
+ private static final String DEBUG_KEY = "org.eclipse.papyrus.uml.diagram.profile/debug/visualID"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static int getVisualID(View view) {
+ if (view instanceof Diagram) {
+ if (ProfileDiagramEditPart.MODEL_ID.equals(view.getType())) {
+ return ProfileDiagramEditPart.VISUAL_ID;
+ } else {
+ return -1;
+ }
+ }
+ return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getVisualID(view.getType());
+ }
+
+ /**
+ * @generated
+ */
+ public static String getModelID(View view) {
+ View diagram = view.getDiagram();
+ while (view != diagram) {
+ EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
+ if (annotation != null) {
+ return (String) annotation.getDetails().get("modelID"); //$NON-NLS-1$
+ }
+ view = (View) view.eContainer();
+ }
+ return diagram != null ? diagram.getType() : null;
+ }
+
+ /**
+ * @generated
+ */
+ public static int getVisualID(String type) {
+ try {
+ return Integer.parseInt(type);
+ } catch (NumberFormatException e) {
+ if (Boolean.TRUE.toString().equalsIgnoreCase(Platform.getDebugOption(DEBUG_KEY))) {
+ UMLDiagramEditorPlugin.getInstance().logError("Unable to parse view type as a visualID number: " + type);
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * @generated
+ */
+ public static String getType(int visualID) {
+ return Integer.toString(visualID);
+ }
+
+ /**
+ * @generated
+ */
+ public static int getDiagramVisualID(EObject domainElement) {
+ if (domainElement == null) {
+ return -1;
+ }
+ return 1000;
+ }
+
+ /**
+ * @generated NOT
+ * we manually test if it's a class or a metaclass
+ */
+ public static int getNodeVisualID(View containerView, EObject domainElement) {
+ if (domainElement == null) {
+ return -1;
+ }
+ String containerModelID = org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getModelID(containerView);
+ if (!ProfileDiagramEditPart.MODEL_ID.equals(containerModelID)) {
+ return -1;
+ }
+ int containerVisualID;
+ if (ProfileDiagramEditPart.MODEL_ID.equals(containerModelID)) {
+ containerVisualID = org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getVisualID(containerView);
+ } else {
+ if (containerView instanceof Diagram) {
+ containerVisualID = ProfileDiagramEditPart.VISUAL_ID;
+ } else {
+ return -1;
+ }
+ }
+ switch (containerVisualID) {
+ case ProfileDiagramEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getDependency().isSuperTypeOf(domainElement.eClass())) {
+ return DependencyNodeEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getAssociation().isSuperTypeOf(domainElement.eClass())) {
+ return AssociationNodeEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getStereotype().isSuperTypeOf(domainElement.eClass())) {
+ return StereotypeEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
+ if (domainElement instanceof Type) {
+ if (Util.isMetaclass((Type) domainElement)) {
+ return MetaclassEditPart.VISUAL_ID;
+ }
+ }
+ return ClassEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
+ return CommentEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
+ return ConstraintEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
+ return ModelEditPartTN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
+ return ProfileEditPartTN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
+ return PackageEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
+ return EnumerationEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
+ return PrimitiveTypeEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypeEditPart.VISUAL_ID;
+ }
+ if (NotationPackage.eINSTANCE.getDiagram().isSuperTypeOf(domainElement.eClass())) {
+ return ShortCutDiagramEditPart.VISUAL_ID;
+ }
+ break;
+ case PackageEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
+ return PackageEditPartCN.VISUAL_ID;
+ }
+ break;
+ case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
+ return CommentEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
+ return ModelEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
+ return ProfileEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
+ return PackageEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
+ return ConstraintEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
+ return EnumerationEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
+ return PrimitiveTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getStereotype().isSuperTypeOf(domainElement.eClass())) {
+ return StereotypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
+ return ClassEditPartCN.VISUAL_ID;
+ }
+ break;
+ case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
+ return CommentEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
+ return ModelEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
+ return ProfileEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
+ return PackageEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
+ return ConstraintEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
+ return EnumerationEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
+ return PrimitiveTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getStereotype().isSuperTypeOf(domainElement.eClass())) {
+ return StereotypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
+ return ClassEditPartCN.VISUAL_ID;
+ }
+ break;
+ case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getStereotype().isSuperTypeOf(domainElement.eClass())) {
+ return StereotypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
+ return ModelEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
+ return ProfileEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
+ return PackageEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
+ return ConstraintEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
+ return EnumerationEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
+ return PrimitiveTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
+ return CommentEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
+ if (domainElement instanceof Type) {
+ if (Util.isMetaclass((Type) domainElement)) {
+ return MetaclassEditPartCN.VISUAL_ID;
+ }
+ }
+ return ClassEditPartCN.VISUAL_ID;
+ }
+ break;
+ case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getStereotype().isSuperTypeOf(domainElement.eClass())) {
+ return StereotypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
+ return ModelEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
+ return ProfileEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
+ return PackageEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
+ return ConstraintEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
+ return EnumerationEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
+ return PrimitiveTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
+ return CommentEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
+ if (domainElement instanceof Type) {
+ if (Util.isMetaclass((Type) domainElement)) {
+ return MetaclassEditPartCN.VISUAL_ID;
+ }
+ }
+ return ClassEditPartCN.VISUAL_ID;
+ }
+ break;
+ case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
+ return ClassPropertyEditPart.VISUAL_ID;
+ }
+ break;
+ case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
+ return ClassPropertyEditPart.VISUAL_ID;
+ }
+ break;
+ case StereotypeOperationCompartmentEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
+ return ClassOperationEditPart.VISUAL_ID;
+ }
+ break;
+ case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
+ return ClassOperationEditPart.VISUAL_ID;
+ }
+ break;
+ case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
+ return CommentEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
+ return ModelEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
+ return ProfileEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
+ return PackageEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
+ return ConstraintEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
+ return EnumerationEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
+ return PrimitiveTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
+ return ClassEditPartCN.VISUAL_ID;
+ }
+ break;
+ case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
+ return CommentEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getModel().isSuperTypeOf(domainElement.eClass())) {
+ return ModelEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getProfile().isSuperTypeOf(domainElement.eClass())) {
+ return ProfileEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPackage().isSuperTypeOf(domainElement.eClass())) {
+ return PackageEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
+ return ConstraintEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getEnumeration().isSuperTypeOf(domainElement.eClass())) {
+ return EnumerationEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPrimitiveType().isSuperTypeOf(domainElement.eClass())) {
+ return PrimitiveTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getDataType().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypeEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getClass_().isSuperTypeOf(domainElement.eClass())) {
+ return ClassEditPartCN.VISUAL_ID;
+ }
+ break;
+ case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getEnumerationLiteral().isSuperTypeOf(domainElement.eClass())) {
+ return EnumerationLiteralEditPart.VISUAL_ID;
+ }
+ break;
+ case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getEnumerationLiteral().isSuperTypeOf(domainElement.eClass())) {
+ return EnumerationLiteralEditPart.VISUAL_ID;
+ }
+ break;
+ case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypePropertyEditPart.VISUAL_ID;
+ }
+ break;
+ case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypePropertyEditPart.VISUAL_ID;
+ }
+ break;
+ case DataTypeOperationCompartmentEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypeOperationEditPart.VISUAL_ID;
+ }
+ break;
+ case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
+ return DataTypeOperationEditPart.VISUAL_ID;
+ }
+ break;
+ case ClassAttributeCompartmentEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
+ return ClassPropertyEditPart.VISUAL_ID;
+ }
+ break;
+ case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass())) {
+ return ClassPropertyEditPart.VISUAL_ID;
+ }
+ break;
+ case ClassOperationCompartmentEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
+ return ClassOperationEditPart.VISUAL_ID;
+ }
+ break;
+ case ClassOperationCompartmentEditPartCN.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getOperation().isSuperTypeOf(domainElement.eClass())) {
+ return ClassOperationEditPart.VISUAL_ID;
+ }
+ break;
+ }
+ return -1;
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean canCreateNode(View containerView, int nodeVisualID) {
+ String containerModelID = org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getModelID(containerView);
+ if (!ProfileDiagramEditPart.MODEL_ID.equals(containerModelID)) {
+ return false;
+ }
+ int containerVisualID;
+ if (ProfileDiagramEditPart.MODEL_ID.equals(containerModelID)) {
+ containerVisualID = org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getVisualID(containerView);
+ } else {
+ if (containerView instanceof Diagram) {
+ containerVisualID = ProfileDiagramEditPart.VISUAL_ID;
+ } else {
+ return false;
+ }
+ }
+ switch (containerVisualID) {
+ case ProfileDiagramEditPart.VISUAL_ID:
+ if (DependencyNodeEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (AssociationNodeEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (StereotypeEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (MetaclassEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (CommentEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ConstraintEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ModelEditPartTN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ProfileEditPartTN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PackageEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (EnumerationEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PrimitiveTypeEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ShortCutDiagramEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case DependencyNodeEditPart.VISUAL_ID:
+ if (MultiDependencyLabelEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case StereotypeEditPart.VISUAL_ID:
+ if (StereotypeNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (StereotypeAttributeCompartmentEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (StereotypeOperationCompartmentEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ClassEditPart.VISUAL_ID:
+ if (ClassNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassOperationCompartmentEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassAttributeCompartmentEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case MetaclassEditPart.VISUAL_ID:
+ if (MetaclassNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case CommentEditPart.VISUAL_ID:
+ if (CommentBodyEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ConstraintEditPart.VISUAL_ID:
+ if (ConstraintNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ConstraintBodyEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ModelEditPartTN.VISUAL_ID:
+ if (ModelNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ModelPackageableElementCompartmentEditPartTN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ProfileEditPartTN.VISUAL_ID:
+ if (ProfileNameEditPartTN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case PackageEditPart.VISUAL_ID:
+ if (PackageNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PackagePackageableElementCompartmentEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case EnumerationEditPart.VISUAL_ID:
+ if (EnumerationNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case PrimitiveTypeEditPart.VISUAL_ID:
+ if (PrimitiveTypeNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case DataTypeEditPart.VISUAL_ID:
+ if (DataTypeNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeAttributeCompartmentEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeOperationCompartmentEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ if (DiagramNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case PrimitiveTypeEditPartCN.VISUAL_ID:
+ if (PrimitiveTypeNameEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case StereotypeEditPartCN.VISUAL_ID:
+ if (StereotypeNameEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (StereotypeAttributeCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (StereotypeOperationCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ClassEditPartCN.VISUAL_ID:
+ if (ClassNameEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassAttributeCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassOperationCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case MetaclassEditPartCN.VISUAL_ID:
+ if (MetaclassNameEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case CommentEditPartCN.VISUAL_ID:
+ if (CommentBodyEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ModelEditPartCN.VISUAL_ID:
+ if (ModelNameEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ModelPackageableElementCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ProfileEditPartCN.VISUAL_ID:
+ if (ProfileNameEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case PackageEditPartCN.VISUAL_ID:
+ if (PackageNameEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PackagePackageableElementCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ConstraintEditPartCN.VISUAL_ID:
+ if (ConstraintNameEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ConstraintBodyEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case EnumerationEditPartCN.VISUAL_ID:
+ if (EnumerationNameEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case DataTypeEditPartCN.VISUAL_ID:
+ if (DataTypeNameEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeAttributeCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeOperationCompartmentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
+ if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (StereotypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (StereotypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
+ if (StereotypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (MetaclassEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ if (StereotypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (MetaclassEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
+ if (ClassPropertyEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ if (ClassPropertyEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case StereotypeOperationCompartmentEditPart.VISUAL_ID:
+ if (ClassOperationEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
+ if (ClassOperationEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
+ if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
+ if (CommentEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ModelEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ProfileEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PackageEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ConstraintEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (EnumerationEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (PrimitiveTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DataTypeEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (ClassEditPartCN.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
+ if (EnumerationLiteralEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
+ if (EnumerationLiteralEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
+ if (DataTypePropertyEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ if (DataTypePropertyEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case DataTypeOperationCompartmentEditPart.VISUAL_ID:
+ if (DataTypeOperationEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
+ if (DataTypeOperationEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ClassAttributeCompartmentEditPart.VISUAL_ID:
+ if (ClassPropertyEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
+ if (ClassPropertyEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ClassOperationCompartmentEditPart.VISUAL_ID:
+ if (ClassOperationEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ClassOperationCompartmentEditPartCN.VISUAL_ID:
+ if (ClassOperationEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case AssociationEditPart.VISUAL_ID:
+ if (AssociationAppliedStereotypeEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (AssociationNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (AssociationRoleTargetEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (AssociationRoleSourceEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (AssociationMultiplicitySourceEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (AssociationMultiplicityTargetEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case AssociationBranchEditPart.VISUAL_ID:
+ if (AssociationBranchRoleEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (AssociationBranchMultiplicityEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case GeneralizationEditPart.VISUAL_ID:
+ if (GeneralizationAppliedStereotypeEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case DependencyEditPart.VISUAL_ID:
+ if (DependencyNameEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (DependencyAppliedStereotypeEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case ElementImportEditPart.VISUAL_ID:
+ if (ElementImportAliasEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ if (AppliedStereotypeElementImportEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ case PackageImportEditPart.VISUAL_ID:
+ if (PackageImportAppliedStereotypeEditPart.VISUAL_ID == nodeVisualID) {
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static int getLinkWithClassVisualID(EObject domainElement) {
+ if (domainElement == null) {
+ return -1;
+ }
+ if (UMLPackage.eINSTANCE.getExtension().isSuperTypeOf(domainElement.eClass())) {
+ return ExtensionEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getAssociation().isSuperTypeOf(domainElement.eClass())) {
+ return AssociationEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getProfileApplication().isSuperTypeOf(domainElement.eClass())) {
+ return ProfileApplicationEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getAssociation().isSuperTypeOf(domainElement.eClass())) {
+ return AssociationBranchEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getGeneralization().isSuperTypeOf(domainElement.eClass())) {
+ return GeneralizationEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getDependency().isSuperTypeOf(domainElement.eClass())) {
+ return DependencyEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getDependency().isSuperTypeOf(domainElement.eClass())) {
+ return DependencyBranchEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getElementImport().isSuperTypeOf(domainElement.eClass())) {
+ return ElementImportEditPart.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getPackageImport().isSuperTypeOf(domainElement.eClass())) {
+ return PackageImportEditPart.VISUAL_ID;
+ }
+ return -1;
+ }
+
+ /**
+ * User can change implementation of this method to handle some specific
+ * situations not covered by default logic.
+ *
+ * @generated
+ */
+ private static boolean isDiagram(Profile element) {
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate) {
+ if (candidate == -1) {
+ //unrecognized id is always bad
+ return false;
+ }
+ int basic = getNodeVisualID(containerView, domainElement);
+ return basic == candidate;
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean isCompartmentVisualID(int visualID) {
+ switch (visualID) {
+ case PackagePackageableElementCompartmentEditPart.VISUAL_ID:
+ case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ case ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID:
+ case ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID:
+ case StereotypeAttributeCompartmentEditPart.VISUAL_ID:
+ case StereotypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ case StereotypeOperationCompartmentEditPart.VISUAL_ID:
+ case StereotypeOperationCompartmentEditPartCN.VISUAL_ID:
+ case ModelPackageableElementCompartmentEditPartTN.VISUAL_ID:
+ case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID:
+ case EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID:
+ case EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID:
+ case DataTypeAttributeCompartmentEditPart.VISUAL_ID:
+ case DataTypeAttributeCompartmentEditPartCN.VISUAL_ID:
+ case DataTypeOperationCompartmentEditPart.VISUAL_ID:
+ case DataTypeOperationCompartmentEditPartCN.VISUAL_ID:
+ case ClassAttributeCompartmentEditPart.VISUAL_ID:
+ case ClassAttributeCompartmentEditPartCN.VISUAL_ID:
+ case ClassOperationCompartmentEditPart.VISUAL_ID:
+ case ClassOperationCompartmentEditPartCN.VISUAL_ID:
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean isSemanticLeafVisualID(int visualID) {
+ switch (visualID) {
+ case ProfileDiagramEditPart.VISUAL_ID:
+ return false;
+ case CommentEditPart.VISUAL_ID:
+ case CommentEditPartCN.VISUAL_ID:
+ case ConstraintEditPart.VISUAL_ID:
+ case ConstraintEditPartCN.VISUAL_ID:
+ case MetaclassEditPart.VISUAL_ID:
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ case PrimitiveTypeEditPart.VISUAL_ID:
+ case DependencyNodeEditPart.VISUAL_ID:
+ case AssociationNodeEditPart.VISUAL_ID:
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ case ClassPropertyEditPart.VISUAL_ID:
+ case DataTypePropertyEditPart.VISUAL_ID:
+ case DataTypeOperationEditPart.VISUAL_ID:
+ case ClassOperationEditPart.VISUAL_ID:
+ case PrimitiveTypeEditPartCN.VISUAL_ID:
+ case MetaclassEditPartCN.VISUAL_ID:
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static final DiagramStructure TYPED_INSTANCE = new DiagramStructure() {
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getVisualID(View view) {
+ return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getVisualID(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getModelID(View view) {
+ return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getModelID(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public int getNodeVisualID(View containerView, EObject domainElement) {
+ return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.getNodeVisualID(containerView, domainElement);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate) {
+ return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.checkNodeVisualID(containerView, domainElement, candidate);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isCompartmentVisualID(int visualID) {
+ return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.isCompartmentVisualID(visualID);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isSemanticLeafVisualID(int visualID) {
+ return org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry.isSemanticLeafVisualID(visualID);
+ }
+ };
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/ValidateAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/ValidateAction.java
index 484e8eb5922..0ca560b948d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/ValidateAction.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/ValidateAction.java
@@ -1,270 +1,298 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.part;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.Diagnostician;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.emf.validation.model.EvaluationMode;
-import org.eclipse.emf.validation.model.IConstraintStatus;
-import org.eclipse.emf.validation.service.IBatchValidator;
-import org.eclipse.emf.validation.service.ModelValidationService;
-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.gmf.runtime.diagram.ui.OffscreenEditPartFactory;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLMarkerNavigationProvider;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLValidationProvider;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-
-/**
- * @generated
- */
-public class ValidateAction extends Action {
-
- /**
- * @generated
- */
- private IWorkbenchPage page;
-
- /**
- * @generated
- */
- public ValidateAction(IWorkbenchPage page) {
- setText(Messages.ValidateActionMessage);
- this.page = page;
- }
-
- /**
- * @generated
- */
- @Override
- public void run() {
- IWorkbenchPart workbenchPart = page.getActivePart();
- if (workbenchPart instanceof IDiagramWorkbenchPart) {
- final IDiagramWorkbenchPart part = (IDiagramWorkbenchPart) workbenchPart;
- try {
- new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
-
- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- runValidation(part.getDiagramEditPart(), part.getDiagram());
- }
- }).run(new NullProgressMonitor());
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * @generated
- */
- public static void runValidation(View view) {
- try {
- if (UMLDiagramEditorUtil.openDiagram(view.eResource())) {
- IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- if (editorPart instanceof IDiagramWorkbenchPart) {
- runValidation(((IDiagramWorkbenchPart) editorPart).getDiagramEditPart(), view);
- } else {
- runNonUIValidation(view);
- }
- }
- } catch (Exception e) {
- UMLDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$
- }
- }
-
- /**
- * @generated
- */
- public static void runNonUIValidation(View view) {
- Shell shell = Display.getCurrent().getActiveShell();
- if (shell == null) {
- shell = new Shell();
- }
- DiagramEditPart diagramEditPart = OffscreenEditPartFactory.getInstance().createDiagramEditPart(view.getDiagram(), shell);
- runValidation(diagramEditPart, view);
- }
-
- /**
- * @generated
- */
- public static void runValidation(DiagramEditPart diagramEditPart, View view) {
- final DiagramEditPart fpart = diagramEditPart;
- final View fview = view;
- TransactionalEditingDomain txDomain = TransactionUtil.getEditingDomain(view);
- UMLValidationProvider.runWithConstraints(txDomain, new Runnable() {
-
- public void run() {
- validate(fpart, fview);
- }
- });
- }
-
- /**
- * @generated
- */
- private static Diagnostic runEMFValidator(View target) {
- if (target.isSetElement() && target.getElement() != null) {
- return new Diagnostician() {
-
- @Override
- public String getObjectLabel(EObject eObject) {
- return EMFCoreUtil.getQualifiedName(eObject, true);
- }
- }.validate(target.getElement());
- }
- return Diagnostic.OK_INSTANCE;
- }
-
- /**
- * @generated
- */
- private static void validate(DiagramEditPart diagramEditPart, View view) {
- IFile target = view.eResource() != null ? WorkspaceSynchronizer.getFile(view.eResource()) : null;
- if (target != null) {
- UMLMarkerNavigationProvider.deleteMarkers(target);
- }
- Diagnostic diagnostic = runEMFValidator(view);
- createMarkers(target, diagnostic, diagramEditPart);
- IBatchValidator validator = (IBatchValidator) ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH);
- validator.setIncludeLiveConstraints(true);
- if (view.isSetElement() && view.getElement() != null) {
- IStatus status = validator.validate(view.getElement());
- createMarkers(target, status, diagramEditPart);
- }
- }
-
- /**
- * @generated
- */
- private static void createMarkers(IFile target, IStatus validationStatus, DiagramEditPart diagramEditPart) {
- if (validationStatus.isOK()) {
- return;
- }
- final IStatus rootStatus = validationStatus;
- List allStatuses = new ArrayList();
- UMLDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new UMLDiagramEditorUtil.LazyElement2ViewMap(diagramEditPart.getDiagramView(), collectTargetElements(rootStatus, new HashSet<EObject>(), allStatuses));
- for (Iterator it = allStatuses.iterator(); it.hasNext();) {
- IConstraintStatus nextStatus = (IConstraintStatus) it.next();
- View view = UMLDiagramEditorUtil.findView(diagramEditPart, nextStatus.getTarget(), element2ViewMap);
- addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view), EMFCoreUtil.getQualifiedName(nextStatus.getTarget(), true), nextStatus.getMessage(), nextStatus.getSeverity());
- }
- }
-
- /**
- * @generated
- */
- private static void createMarkers(IFile target, Diagnostic emfValidationStatus, DiagramEditPart diagramEditPart) {
- if (emfValidationStatus.getSeverity() == Diagnostic.OK) {
- return;
- }
- final Diagnostic rootStatus = emfValidationStatus;
- List<Diagnostic> allDiagnostics = new ArrayList<Diagnostic>();
- UMLDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new UMLDiagramEditorUtil.LazyElement2ViewMap(diagramEditPart.getDiagramView(), collectTargetElements(rootStatus, new HashSet<EObject>(), allDiagnostics));
- for (Iterator<Diagnostic> it = emfValidationStatus.getChildren().iterator(); it.hasNext();) {
- Diagnostic nextDiagnostic = it.next();
- List<?> data = nextDiagnostic.getData();
- if (data != null && !data.isEmpty() && data.get(0) instanceof EObject) {
- EObject element = (EObject) data.get(0);
- View view = UMLDiagramEditorUtil.findView(diagramEditPart, element, element2ViewMap);
- addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view), EMFCoreUtil.getQualifiedName(element, true), nextDiagnostic.getMessage(), diagnosticToStatusSeverity(nextDiagnostic.getSeverity()));
- }
- }
- }
-
- /**
- * @generated
- */
- private static void addMarker(EditPartViewer viewer, IFile target, String elementId, String location, String message, int statusSeverity) {
- if (target == null) {
- return;
- }
- UMLMarkerNavigationProvider.addMarker(target, elementId, location, message, statusSeverity);
- }
-
- /**
- * @generated
- */
- private static int diagnosticToStatusSeverity(int diagnosticSeverity) {
- if (diagnosticSeverity == Diagnostic.OK) {
- return IStatus.OK;
- } else if (diagnosticSeverity == Diagnostic.INFO) {
- return IStatus.INFO;
- } else if (diagnosticSeverity == Diagnostic.WARNING) {
- return IStatus.WARNING;
- } else if (diagnosticSeverity == Diagnostic.ERROR || diagnosticSeverity == Diagnostic.CANCEL) {
- return IStatus.ERROR;
- }
- return IStatus.INFO;
- }
-
- /**
- * @generated
- */
- private static Set<EObject> collectTargetElements(IStatus status, Set<EObject> targetElementCollector, List<IConstraintStatus> allConstraintStatuses) {
- if (status instanceof IConstraintStatus) {
- targetElementCollector.add(((IConstraintStatus) status).getTarget());
- allConstraintStatuses.add((IConstraintStatus) status);
- }
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- collectTargetElements(children[i], targetElementCollector, allConstraintStatuses);
- }
- }
- return targetElementCollector;
- }
-
- /**
- * @generated
- */
- private static Set<EObject> collectTargetElements(Diagnostic diagnostic, Set<EObject> targetElementCollector, List<Diagnostic> allDiagnostics) {
- List<?> data = diagnostic.getData();
- EObject target = null;
- if (data != null && !data.isEmpty() && data.get(0) instanceof EObject) {
- target = (EObject) data.get(0);
- targetElementCollector.add(target);
- allDiagnostics.add(diagnostic);
- }
- if (diagnostic.getChildren() != null && !diagnostic.getChildren().isEmpty()) {
- for (Iterator<Diagnostic> it = diagnostic.getChildren().iterator(); it.hasNext();) {
- collectTargetElements(it.next(), targetElementCollector, allDiagnostics);
- }
- }
- return targetElementCollector;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.part;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.emf.validation.model.EvaluationMode;
+import org.eclipse.emf.validation.model.IConstraintStatus;
+import org.eclipse.emf.validation.service.IBatchValidator;
+import org.eclipse.emf.validation.service.ModelValidationService;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gmf.runtime.diagram.ui.OffscreenEditPartFactory;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLMarkerNavigationProvider;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLValidationProvider;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+
+/**
+ * @generated
+ */
+public class ValidateAction extends Action {
+
+ /**
+ * @generated
+ */
+ private IWorkbenchPage page;
+
+ /**
+ * @generated
+ */
+ public ValidateAction(IWorkbenchPage page) {
+ setText(Messages.ValidateActionMessage);
+ this.page = page;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public void run() {
+ IWorkbenchPart workbenchPart = page.getActivePart();
+ if (workbenchPart instanceof IDiagramWorkbenchPart) {
+ final IDiagramWorkbenchPart part = (IDiagramWorkbenchPart) workbenchPart;
+ try {
+ new WorkspaceModifyDelegatingOperation(
+ new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor)
+ throws InterruptedException, InvocationTargetException {
+ runValidation(part.getDiagramEditPart(), part.getDiagram());
+ }
+ })
+ .run(new NullProgressMonitor());
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public static void runValidation(View view) {
+ try {
+ if (UMLDiagramEditorUtil.openDiagram(view.eResource())) {
+ IEditorPart editorPart = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if (editorPart instanceof IDiagramWorkbenchPart) {
+ runValidation(((IDiagramWorkbenchPart) editorPart).
+ getDiagramEditPart(), view);
+ } else {
+ runNonUIValidation(view);
+ }
+ }
+ } catch (Exception e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public static void runNonUIValidation(View view) {
+ Shell shell = Display.getCurrent().getActiveShell();
+ if (shell == null) {
+ shell = new Shell();
+ }
+ DiagramEditPart diagramEditPart =
+ OffscreenEditPartFactory.getInstance().createDiagramEditPart(
+ view.getDiagram(), shell);
+ runValidation(diagramEditPart, view);
+ }
+
+ /**
+ * @generated
+ */
+ public static void runValidation(DiagramEditPart diagramEditPart, View view) {
+ final DiagramEditPart fpart = diagramEditPart;
+ final View fview = view;
+ TransactionalEditingDomain txDomain = TransactionUtil.getEditingDomain(view);
+ UMLValidationProvider.runWithConstraints(txDomain, new Runnable() {
+
+ public void run() {
+ validate(fpart, fview);
+ }
+ });
+ }
+
+ /**
+ * @generated
+ */
+ private static Diagnostic runEMFValidator(View target) {
+ if (target.isSetElement() && target.getElement() != null) {
+ return new Diagnostician() {
+
+ public String getObjectLabel(EObject eObject) {
+ return EMFCoreUtil.getQualifiedName(eObject, true);
+ }
+ }.validate(target.getElement());
+ }
+ return Diagnostic.OK_INSTANCE;
+ }
+
+ /**
+ * @generated
+ */
+ private static void validate(DiagramEditPart diagramEditPart, View view) {
+ IFile target = view.eResource() != null ?
+ WorkspaceSynchronizer.getFile(view.eResource()) : null;
+ if (target != null) {
+ UMLMarkerNavigationProvider.deleteMarkers(target);
+ }
+ Diagnostic diagnostic = runEMFValidator(view);
+ createMarkers(target, diagnostic, diagramEditPart);
+ IBatchValidator validator =
+ (IBatchValidator)
+ ModelValidationService.getInstance().newValidator(
+ EvaluationMode.BATCH);
+ validator.setIncludeLiveConstraints(true);
+ if (view.isSetElement() && view.getElement() != null) {
+ IStatus status = validator.validate(view.getElement());
+ createMarkers(target, status, diagramEditPart);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private static void createMarkers(IFile
+ target, IStatus validationStatus, DiagramEditPart diagramEditPart) {
+ if (validationStatus.isOK()) {
+ return;
+ }
+ final IStatus rootStatus = validationStatus;
+ List allStatuses = new ArrayList();
+ UMLDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new UMLDiagramEditorUtil.LazyElement2ViewMap(
+ diagramEditPart.getDiagramView(),
+ collectTargetElements(rootStatus, new HashSet<EObject>(), allStatuses));
+ for (Iterator it = allStatuses.iterator(); it.hasNext();) {
+ IConstraintStatus nextStatus =
+ (IConstraintStatus) it.next();
+ View view = UMLDiagramEditorUtil.findView(
+ diagramEditPart, nextStatus.getTarget(), element2ViewMap);
+ addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view),
+ EMFCoreUtil.getQualifiedName(nextStatus.getTarget(), true),
+ nextStatus.getMessage(), nextStatus.getSeverity());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private static void createMarkers(IFile
+ target, Diagnostic emfValidationStatus, DiagramEditPart diagramEditPart) {
+ if (emfValidationStatus.getSeverity() == Diagnostic.OK) {
+ return;
+ }
+ final Diagnostic rootStatus = emfValidationStatus;
+ List<Diagnostic> allDiagnostics = new ArrayList<Diagnostic>();
+ UMLDiagramEditorUtil.LazyElement2ViewMap element2ViewMap =
+ new UMLDiagramEditorUtil.LazyElement2ViewMap(
+ diagramEditPart.getDiagramView(),
+ collectTargetElements(rootStatus, new HashSet<EObject>(), allDiagnostics));
+ for (Iterator<Diagnostic> it = emfValidationStatus.getChildren().iterator(); it.hasNext();) {
+ Diagnostic nextDiagnostic = (Diagnostic) it.next();
+ List<?> data = nextDiagnostic.getData();
+ if (data != null && !data.isEmpty() && data.get(0) instanceof EObject) {
+ EObject element = (EObject) data.get(0);
+ View view = UMLDiagramEditorUtil.findView(
+ diagramEditPart, element, element2ViewMap);
+ addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view),
+ EMFCoreUtil.getQualifiedName(element, true),
+ nextDiagnostic.getMessage(), diagnosticToStatusSeverity(nextDiagnostic.getSeverity()));
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private static void addMarker(EditPartViewer viewer, IFile
+ target, String elementId, String location, String message, int statusSeverity) {
+ if (target == null) {
+ return;
+ }
+ UMLMarkerNavigationProvider.addMarker(
+ target, elementId, location, message, statusSeverity);
+ }
+
+ /**
+ * @generated
+ */
+ private static int diagnosticToStatusSeverity(int diagnosticSeverity) {
+ if (diagnosticSeverity == Diagnostic.OK) {
+ return IStatus.OK;
+ } else if (diagnosticSeverity == Diagnostic.INFO) {
+ return IStatus.INFO;
+ } else if (diagnosticSeverity == Diagnostic.WARNING) {
+ return IStatus.WARNING;
+ } else if (diagnosticSeverity == Diagnostic.ERROR
+ || diagnosticSeverity == Diagnostic.CANCEL) {
+ return IStatus.ERROR;
+ }
+ return IStatus.INFO;
+ }
+
+ /**
+ * @generated
+ */
+ private static Set<EObject> collectTargetElements(IStatus status, Set<EObject> targetElementCollector, List<IConstraintStatus> allConstraintStatuses) {
+ if (status instanceof IConstraintStatus) {
+ targetElementCollector.add(((IConstraintStatus) status).getTarget());
+ allConstraintStatuses.add((IConstraintStatus) status);
+ }
+ if (status.isMultiStatus()) {
+ IStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ collectTargetElements(children[i], targetElementCollector, allConstraintStatuses);
+ }
+ }
+ return targetElementCollector;
+ }
+
+ /**
+ * @generated
+ */
+ private static Set<EObject> collectTargetElements(Diagnostic diagnostic, Set<EObject> targetElementCollector, List<Diagnostic> allDiagnostics) {
+ List<?> data = diagnostic.getData();
+ EObject target = null;
+ if (data != null && !data.isEmpty() && data.get(0) instanceof EObject) {
+ target = (EObject) data.get(0);
+ targetElementCollector.add(target);
+ allDiagnostics.add(diagnostic);
+ }
+ if (diagnostic.getChildren() != null && !diagnostic.getChildren().isEmpty()) {
+ for (Iterator<Diagnostic> it = diagnostic.getChildren().iterator(); it.hasNext();) {
+ collectTargetElements((Diagnostic) it.next(),
+ targetElementCollector, allDiagnostics);
+ }
+ }
+ return targetElementCollector;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/preferences/DiagramPreferenceInitializer.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/preferences/DiagramPreferenceInitializer.java
index 0c3e15b9218..acfebf50a26 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/preferences/DiagramPreferenceInitializer.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/preferences/DiagramPreferenceInitializer.java
@@ -1,47 +1,47 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.preferences;
-
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.gmf.runtime.diagram.ui.preferences.AppearancePreferencePage;
-import org.eclipse.gmf.runtime.diagram.ui.preferences.ConnectionsPreferencePage;
-import org.eclipse.gmf.runtime.diagram.ui.preferences.DiagramsPreferencePage;
-import org.eclipse.gmf.runtime.diagram.ui.preferences.PrintingPreferencePage;
-import org.eclipse.gmf.runtime.diagram.ui.preferences.RulerGridPreferencePage;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
-
-/**
- * @generated
- */
-public class DiagramPreferenceInitializer extends AbstractPreferenceInitializer {
-
- /**
- * @generated
- */
- @Override
- public void initializeDefaultPreferences() {
- IPreferenceStore store = getPreferenceStore();
- DiagramsPreferencePage.initDefaults(store);
- AppearancePreferencePage.initDefaults(store);
- ConnectionsPreferencePage.initDefaults(store);
- PrintingPreferencePage.initDefaults(store);
- RulerGridPreferencePage.initDefaults(store);
- }
-
- /**
- * @generated
- */
- protected IPreferenceStore getPreferenceStore() {
- return UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.gmf.runtime.diagram.ui.preferences.AppearancePreferencePage;
+import org.eclipse.gmf.runtime.diagram.ui.preferences.ConnectionsPreferencePage;
+import org.eclipse.gmf.runtime.diagram.ui.preferences.DiagramsPreferencePage;
+import org.eclipse.gmf.runtime.diagram.ui.preferences.PrintingPreferencePage;
+import org.eclipse.gmf.runtime.diagram.ui.preferences.RulerGridPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
+
+/**
+ * @generated
+ */
+public class DiagramPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /**
+ * @generated
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = getPreferenceStore();
+ DiagramGeneralPreferencePage.initDefaults(store);
+ DiagramAppearancePreferencePage.initDefaults(store);
+ DiagramConnectionsPreferencePage.initDefaults(store);
+ DiagramPrintingPreferencePage.initDefaults(store);
+ DiagramRulersAndGridPreferencePage.initDefaults(store);
+ }
+
+ /**
+ * @generated
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ return UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/ElementInitializers.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/ElementInitializers.java
index 45ef191463b..c021c343574 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/ElementInitializers.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/ElementInitializers.java
@@ -49,10 +49,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Stereotype_1026(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -63,10 +65,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Class_2008(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -77,10 +81,12 @@ public class ElementInitializers {
try {
Object value_0 = isAbstract_Class_1031(instance);
if (value_0 != null) {
- instance.setIsAbstract(((Boolean) value_0).booleanValue());
+ instance.setIsAbstract(
+ ((Boolean) value_0).booleanValue()
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -91,10 +97,12 @@ public class ElementInitializers {
try {
Object value_0 = body_Comment_1002(instance);
if (value_0 != null) {
- instance.setBody((String) value_0);
+ instance.setBody(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -105,14 +113,18 @@ public class ElementInitializers {
try {
Object value_0 = name_Constraint_1014(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
Object value_1 = specification_Constraint_1014(instance);
if (value_1 != null) {
- instance.setSpecification((ValueSpecification) value_1);
+ instance.setSpecification(
+ (ValueSpecification) value_1
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -123,10 +135,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Model_2005(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -137,10 +151,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Profile_1030(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -151,10 +167,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Package_2007(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -165,10 +183,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Enumeration_2006(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -179,10 +199,12 @@ public class ElementInitializers {
try {
Object value_0 = name_PrimitiveType_2009(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -193,10 +215,12 @@ public class ElementInitializers {
try {
Object value_0 = name_DataType_2010(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -207,10 +231,12 @@ public class ElementInitializers {
try {
Object value_0 = name_PrimitiveType_3026(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -221,10 +247,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Operation_3019(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -235,10 +263,12 @@ public class ElementInitializers {
try {
Object value_0 = name_EnumerationLiteral_1037(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -249,10 +279,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Property_3018(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -263,10 +295,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Property_3002(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -277,10 +311,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Operation_3020(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -291,10 +327,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Stereotype_1023(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -305,10 +343,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Class_3010(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -319,10 +359,12 @@ public class ElementInitializers {
try {
Object value_0 = isAbstract_Class_3028(instance);
if (value_0 != null) {
- instance.setIsAbstract(((Boolean) value_0).booleanValue());
+ instance.setIsAbstract(
+ ((Boolean) value_0).booleanValue()
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -333,10 +375,12 @@ public class ElementInitializers {
try {
Object value_0 = body_Comment_1007(instance);
if (value_0 != null) {
- instance.setBody((String) value_0);
+ instance.setBody(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -347,10 +391,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Model_1027(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -361,10 +407,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Profile_1024(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -375,10 +423,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Package_1012(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -389,14 +439,18 @@ public class ElementInitializers {
try {
Object value_0 = name_Constraint_1028(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
Object value_1 = specification_Constraint_1028(instance);
if (value_1 != null) {
- instance.setSpecification((ValueSpecification) value_1);
+ instance.setSpecification(
+ (ValueSpecification) value_1
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -407,10 +461,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Enumeration_3025(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -421,10 +477,12 @@ public class ElementInitializers {
try {
Object value_0 = name_DataType_3027(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -435,10 +493,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Association_4001(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -449,10 +509,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Dependency_4008(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -463,10 +525,12 @@ public class ElementInitializers {
try {
Object value_0 = name_Dependency_4018(instance);
if (value_0 != null) {
- instance.setName((String) value_0);
+ instance.setName(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -477,10 +541,12 @@ public class ElementInitializers {
try {
Object value_0 = alias_ElementImport_1064(instance);
if (value_0 != null) {
- instance.setAlias((String) value_0);
+ instance.setAlias(
+ (String) value_0
+ );
}
} catch (RuntimeException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
@@ -502,7 +568,7 @@ public class ElementInitializers {
* @generated
*/
private Boolean isAbstract_Class_1031(Class it) {
- // isAbstract = true
+ //isAbstract = true
return true;
}
@@ -631,7 +697,7 @@ public class ElementInitializers {
* @generated
*/
private Boolean isAbstract_Class_3028(Class it) {
- // isAbstract = true
+ //isAbstract = true
return true;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLEditPartProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLEditPartProvider.java
index 8592c383934..43cd669d1d1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLEditPartProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLEditPartProvider.java
@@ -1,30 +1,32 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.providers;
-
-import org.eclipse.gmf.tooling.runtime.providers.DefaultEditPartProvider;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.UMLEditPartFactory;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-
-/**
- * @generated
- */
-public class UMLEditPartProvider extends DefaultEditPartProvider {
-
- /**
- * @generated
- */
- public UMLEditPartProvider() {
- super(new UMLEditPartFactory(), UMLVisualIDRegistry.TYPED_INSTANCE, ProfileDiagramEditPart.MODEL_ID);
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.providers;
+
+import org.eclipse.gmf.tooling.runtime.providers.DefaultEditPartProvider;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.UMLEditPartFactory;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+
+/**
+ * @generated
+ */
+public class UMLEditPartProvider extends DefaultEditPartProvider {
+
+ /**
+ * @generated
+ */
+ public UMLEditPartProvider() {
+ super(new UMLEditPartFactory(),
+ UMLVisualIDRegistry.TYPED_INSTANCE,
+ ProfileDiagramEditPart.MODEL_ID);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLElementTypes.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLElementTypes.java
index eb4f29aeb72..e6ca374f94c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLElementTypes.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLElementTypes.java
@@ -1,583 +1,583 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.providers;
-
-import java.util.HashSet;
-import java.util.IdentityHashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.tooling.runtime.providers.DiagramElementTypeImages;
-import org.eclipse.gmf.tooling.runtime.providers.DiagramElementTypes;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNodeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ShortCutDiagramEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class UMLElementTypes {
-
- /**
- * @generated
- */
- private UMLElementTypes() {
- }
-
- /**
- * @generated
- */
- private static Map<IElementType, ENamedElement> elements;
-
- /**
- * @generated
- */
- private static DiagramElementTypeImages elementTypeImages = new DiagramElementTypeImages(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory());
-
- /**
- * @generated
- */
- private static Set<IElementType> KNOWN_ELEMENT_TYPES;
-
- /**
- * @generated
- */
- public static final IElementType Profile_1000 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Profile_1000"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Dependency_2014 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Dependency_2014"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Association_2015 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Association_2015"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Stereotype_1026 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Stereotype_1026"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Class_2008 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Class_2008"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Class_1031 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Metaclass_1031"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Comment_1002 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Comment_1002"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Constraint_1014 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Constraint_1014"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Model_2005 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Model_2005"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Profile_1030 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Profile_1030"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Package_2007 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Package_1004"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Enumeration_2006 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Enumeration_2006"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType PrimitiveType_2009 = getElementType("org.eclipse.papyrus.uml.diagram.profile.PrimitiveType_2009"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType DataType_2010 = getElementType("org.eclipse.papyrus.uml.diagram.profile.DataType_2010"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Diagram_2016 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Diagram_2016"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType PrimitiveType_3026 = getElementType("org.eclipse.papyrus.uml.diagram.profile.PrimitiveType_3026"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Operation_3019 = getElementType("org.eclipse.papyrus.uml.diagram.profile.DataTypeOperation_3019"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType EnumerationLiteral_1037 = getElementType("org.eclipse.papyrus.uml.diagram.profile.EnumerationLiteral_1037"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Property_3018 = getElementType("org.eclipse.papyrus.uml.diagram.profile.DataTypeProperty_3018"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Property_3002 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ClassProperty_3002"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Operation_3020 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ClassOperation_3020"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Stereotype_1023 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Stereotype_1023"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Class_3010 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Class_3010"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Class_3028 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Metaclass_3028"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Comment_1007 = getElementType("org.eclipse.papyrus.uml.diagram.profile.CommentCN_1007"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Model_1027 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Model_1027"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Profile_1024 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Profile_1024"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Package_1012 = getElementType("org.eclipse.papyrus.uml.diagram.profile.PackageCN_1012"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Constraint_1028 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Constraint_1028"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Enumeration_3025 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Enumeration_3025"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType DataType_3027 = getElementType("org.eclipse.papyrus.uml.diagram.profile.DataType_3027"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Extension_1013 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Extension_1013"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Association_4001 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Association_4001"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType ProfileApplication_1045 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ProfileApplication_1045"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Association_4019 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Association_4019"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Generalization_4002 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Generalization_4002"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Dependency_4008 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Dependency_4008"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType Dependency_4018 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Dependency_4018"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType ElementImport_1064 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ElementImport_1064"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType PackageImport_1065 = getElementType("org.eclipse.papyrus.uml.diagram.profile.PackageImport_1065"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType CommentAnnotatedElement_1022 = getElementType("org.eclipse.papyrus.uml.diagram.profile.CommentAnnotatedElement_1022"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType ConstraintConstrainedElement_4014 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ConstraintConstrainedElement_4014"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final IElementType ConstraintContext_8500 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ConstraintContext_8500"); //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static ImageDescriptor getImageDescriptor(ENamedElement element) {
- return elementTypeImages.getImageDescriptor(element);
- }
-
- /**
- * @generated
- */
- public static Image getImage(ENamedElement element) {
- return elementTypeImages.getImage(element);
- }
-
- /**
- * @generated
- */
- public static ImageDescriptor getImageDescriptor(IAdaptable hint) {
- return getImageDescriptor(getElement(hint));
- }
-
- /**
- * @generated
- */
- public static Image getImage(IAdaptable hint) {
- return getImage(getElement(hint));
- }
-
- /**
- * Returns 'type' of the ecore object associated with the hint.
- *
- * @generated
- */
- public static synchronized ENamedElement getElement(IAdaptable hint) {
- Object type = hint.getAdapter(IElementType.class);
- if (elements == null) {
- elements = new IdentityHashMap<IElementType, ENamedElement>();
- elements.put(Profile_1000, UMLPackage.eINSTANCE.getProfile());
- elements.put(Dependency_2014, UMLPackage.eINSTANCE.getDependency());
- elements.put(Association_2015, UMLPackage.eINSTANCE.getAssociation());
- elements.put(Stereotype_1026, UMLPackage.eINSTANCE.getStereotype());
- elements.put(Class_2008, UMLPackage.eINSTANCE.getClass_());
- elements.put(Class_1031, UMLPackage.eINSTANCE.getClass_());
- elements.put(Comment_1002, UMLPackage.eINSTANCE.getComment());
- elements.put(Constraint_1014, UMLPackage.eINSTANCE.getConstraint());
- elements.put(Model_2005, UMLPackage.eINSTANCE.getModel());
- elements.put(Profile_1030, UMLPackage.eINSTANCE.getProfile());
- elements.put(Package_2007, UMLPackage.eINSTANCE.getPackage());
- elements.put(Enumeration_2006, UMLPackage.eINSTANCE.getEnumeration());
- elements.put(PrimitiveType_2009, UMLPackage.eINSTANCE.getPrimitiveType());
- elements.put(DataType_2010, UMLPackage.eINSTANCE.getDataType());
- elements.put(Diagram_2016, NotationPackage.eINSTANCE.getDiagram());
- elements.put(PrimitiveType_3026, UMLPackage.eINSTANCE.getPrimitiveType());
- elements.put(Operation_3019, UMLPackage.eINSTANCE.getOperation());
- elements.put(EnumerationLiteral_1037, UMLPackage.eINSTANCE.getEnumerationLiteral());
- elements.put(Property_3018, UMLPackage.eINSTANCE.getProperty());
- elements.put(Property_3002, UMLPackage.eINSTANCE.getProperty());
- elements.put(Operation_3020, UMLPackage.eINSTANCE.getOperation());
- elements.put(Stereotype_1023, UMLPackage.eINSTANCE.getStereotype());
- elements.put(Class_3010, UMLPackage.eINSTANCE.getClass_());
- elements.put(Class_3028, UMLPackage.eINSTANCE.getClass_());
- elements.put(Comment_1007, UMLPackage.eINSTANCE.getComment());
- elements.put(Model_1027, UMLPackage.eINSTANCE.getModel());
- elements.put(Profile_1024, UMLPackage.eINSTANCE.getProfile());
- elements.put(Package_1012, UMLPackage.eINSTANCE.getPackage());
- elements.put(Constraint_1028, UMLPackage.eINSTANCE.getConstraint());
- elements.put(Enumeration_3025, UMLPackage.eINSTANCE.getEnumeration());
- elements.put(DataType_3027, UMLPackage.eINSTANCE.getDataType());
- elements.put(Extension_1013, UMLPackage.eINSTANCE.getExtension());
- elements.put(Association_4001, UMLPackage.eINSTANCE.getAssociation());
- elements.put(ProfileApplication_1045, UMLPackage.eINSTANCE.getProfileApplication());
- elements.put(Association_4019, UMLPackage.eINSTANCE.getAssociation());
- elements.put(Generalization_4002, UMLPackage.eINSTANCE.getGeneralization());
- elements.put(Dependency_4008, UMLPackage.eINSTANCE.getDependency());
- elements.put(Dependency_4018, UMLPackage.eINSTANCE.getDependency());
- elements.put(ElementImport_1064, UMLPackage.eINSTANCE.getElementImport());
- elements.put(PackageImport_1065, UMLPackage.eINSTANCE.getPackageImport());
- elements.put(CommentAnnotatedElement_1022, UMLPackage.eINSTANCE.getComment_AnnotatedElement());
- elements.put(ConstraintConstrainedElement_4014, UMLPackage.eINSTANCE.getConstraint_ConstrainedElement());
- elements.put(ConstraintContext_8500, UMLPackage.eINSTANCE.getConstraint_Context());
- }
- return elements.get(type);
- }
-
- /**
- * @generated
- */
- private static IElementType getElementType(String id) {
- return ElementTypeRegistry.getInstance().getType(id);
- }
-
- /**
- * @generated
- */
- public static synchronized boolean isKnownElementType(IElementType elementType) {
- if (KNOWN_ELEMENT_TYPES == null) {
- KNOWN_ELEMENT_TYPES = new HashSet<IElementType>();
- KNOWN_ELEMENT_TYPES.add(Profile_1000);
- KNOWN_ELEMENT_TYPES.add(Dependency_2014);
- KNOWN_ELEMENT_TYPES.add(Association_2015);
- KNOWN_ELEMENT_TYPES.add(Stereotype_1026);
- KNOWN_ELEMENT_TYPES.add(Class_2008);
- KNOWN_ELEMENT_TYPES.add(Class_1031);
- KNOWN_ELEMENT_TYPES.add(Comment_1002);
- KNOWN_ELEMENT_TYPES.add(Constraint_1014);
- KNOWN_ELEMENT_TYPES.add(Model_2005);
- KNOWN_ELEMENT_TYPES.add(Profile_1030);
- KNOWN_ELEMENT_TYPES.add(Package_2007);
- KNOWN_ELEMENT_TYPES.add(Enumeration_2006);
- KNOWN_ELEMENT_TYPES.add(PrimitiveType_2009);
- KNOWN_ELEMENT_TYPES.add(DataType_2010);
- KNOWN_ELEMENT_TYPES.add(Diagram_2016);
- KNOWN_ELEMENT_TYPES.add(PrimitiveType_3026);
- KNOWN_ELEMENT_TYPES.add(Operation_3019);
- KNOWN_ELEMENT_TYPES.add(EnumerationLiteral_1037);
- KNOWN_ELEMENT_TYPES.add(Property_3018);
- KNOWN_ELEMENT_TYPES.add(Property_3002);
- KNOWN_ELEMENT_TYPES.add(Operation_3020);
- KNOWN_ELEMENT_TYPES.add(Stereotype_1023);
- KNOWN_ELEMENT_TYPES.add(Class_3010);
- KNOWN_ELEMENT_TYPES.add(Class_3028);
- KNOWN_ELEMENT_TYPES.add(Comment_1007);
- KNOWN_ELEMENT_TYPES.add(Model_1027);
- KNOWN_ELEMENT_TYPES.add(Profile_1024);
- KNOWN_ELEMENT_TYPES.add(Package_1012);
- KNOWN_ELEMENT_TYPES.add(Constraint_1028);
- KNOWN_ELEMENT_TYPES.add(Enumeration_3025);
- KNOWN_ELEMENT_TYPES.add(DataType_3027);
- KNOWN_ELEMENT_TYPES.add(Extension_1013);
- KNOWN_ELEMENT_TYPES.add(Association_4001);
- KNOWN_ELEMENT_TYPES.add(ProfileApplication_1045);
- KNOWN_ELEMENT_TYPES.add(Association_4019);
- KNOWN_ELEMENT_TYPES.add(Generalization_4002);
- KNOWN_ELEMENT_TYPES.add(Dependency_4008);
- KNOWN_ELEMENT_TYPES.add(Dependency_4018);
- KNOWN_ELEMENT_TYPES.add(ElementImport_1064);
- KNOWN_ELEMENT_TYPES.add(PackageImport_1065);
- KNOWN_ELEMENT_TYPES.add(CommentAnnotatedElement_1022);
- KNOWN_ELEMENT_TYPES.add(ConstraintConstrainedElement_4014);
- KNOWN_ELEMENT_TYPES.add(ConstraintContext_8500);
- }
- return KNOWN_ELEMENT_TYPES.contains(elementType);
- }
-
- /**
- * @generated
- */
- public static IElementType getElementType(int visualID) {
- switch (visualID) {
- case ProfileDiagramEditPart.VISUAL_ID:
- return Profile_1000;
- case DependencyNodeEditPart.VISUAL_ID:
- return Dependency_2014;
- case AssociationNodeEditPart.VISUAL_ID:
- return Association_2015;
- case StereotypeEditPart.VISUAL_ID:
- return Stereotype_1026;
- case ClassEditPart.VISUAL_ID:
- return Class_2008;
- case MetaclassEditPart.VISUAL_ID:
- return Class_1031;
- case CommentEditPart.VISUAL_ID:
- return Comment_1002;
- case ConstraintEditPart.VISUAL_ID:
- return Constraint_1014;
- case ModelEditPartTN.VISUAL_ID:
- return Model_2005;
- case ProfileEditPartTN.VISUAL_ID:
- return Profile_1030;
- case PackageEditPart.VISUAL_ID:
- return Package_2007;
- case EnumerationEditPart.VISUAL_ID:
- return Enumeration_2006;
- case PrimitiveTypeEditPart.VISUAL_ID:
- return PrimitiveType_2009;
- case DataTypeEditPart.VISUAL_ID:
- return DataType_2010;
- case ShortCutDiagramEditPart.VISUAL_ID:
- return Diagram_2016;
- case PrimitiveTypeEditPartCN.VISUAL_ID:
- return PrimitiveType_3026;
- case DataTypeOperationEditPart.VISUAL_ID:
- return Operation_3019;
- case EnumerationLiteralEditPart.VISUAL_ID:
- return EnumerationLiteral_1037;
- case DataTypePropertyEditPart.VISUAL_ID:
- return Property_3018;
- case ClassPropertyEditPart.VISUAL_ID:
- return Property_3002;
- case ClassOperationEditPart.VISUAL_ID:
- return Operation_3020;
- case StereotypeEditPartCN.VISUAL_ID:
- return Stereotype_1023;
- case ClassEditPartCN.VISUAL_ID:
- return Class_3010;
- case MetaclassEditPartCN.VISUAL_ID:
- return Class_3028;
- case CommentEditPartCN.VISUAL_ID:
- return Comment_1007;
- case ModelEditPartCN.VISUAL_ID:
- return Model_1027;
- case ProfileEditPartCN.VISUAL_ID:
- return Profile_1024;
- case PackageEditPartCN.VISUAL_ID:
- return Package_1012;
- case ConstraintEditPartCN.VISUAL_ID:
- return Constraint_1028;
- case EnumerationEditPartCN.VISUAL_ID:
- return Enumeration_3025;
- case DataTypeEditPartCN.VISUAL_ID:
- return DataType_3027;
- case ExtensionEditPart.VISUAL_ID:
- return Extension_1013;
- case AssociationEditPart.VISUAL_ID:
- return Association_4001;
- case ProfileApplicationEditPart.VISUAL_ID:
- return ProfileApplication_1045;
- case AssociationBranchEditPart.VISUAL_ID:
- return Association_4019;
- case GeneralizationEditPart.VISUAL_ID:
- return Generalization_4002;
- case DependencyEditPart.VISUAL_ID:
- return Dependency_4008;
- case DependencyBranchEditPart.VISUAL_ID:
- return Dependency_4018;
- case ElementImportEditPart.VISUAL_ID:
- return ElementImport_1064;
- case PackageImportEditPart.VISUAL_ID:
- return PackageImport_1065;
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return CommentAnnotatedElement_1022;
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return ConstraintConstrainedElement_4014;
- case ContextLinkEditPart.VISUAL_ID:
- return ConstraintContext_8500;
- }
- return null;
- }
-
- /**
- * @generated
- */
- public static final DiagramElementTypes TYPED_INSTANCE = new DiagramElementTypes(elementTypeImages) {
-
- /**
- * @generated
- */
- @Override
- public boolean isKnownElementType(IElementType elementType) {
- return org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes.isKnownElementType(elementType);
- }
-
- /**
- * @generated
- */
- @Override
- public IElementType getElementTypeForVisualId(int visualID) {
- return org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes.getElementType(visualID);
- }
-
- /**
- * @generated
- */
- @Override
- public ENamedElement getDefiningNamedElement(IAdaptable elementTypeAdapter) {
- return org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes.getElement(elementTypeAdapter);
- }
- };
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.providers;
+
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.tooling.runtime.providers.DiagramElementTypeImages;
+import org.eclipse.gmf.tooling.runtime.providers.DiagramElementTypes;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ContextLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyBranchEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ExtensionEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileApplicationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ShortCutDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class UMLElementTypes {
+
+ /**
+ * @generated
+ */
+ private UMLElementTypes() {
+ }
+
+ /**
+ * @generated
+ */
+ private static Map<IElementType, ENamedElement> elements;
+
+ /**
+ * @generated
+ */
+ private static DiagramElementTypeImages elementTypeImages = new DiagramElementTypeImages(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory());
+
+ /**
+ * @generated
+ */
+ private static Set<IElementType> KNOWN_ELEMENT_TYPES;
+
+ /**
+ * @generated
+ */
+ public static final IElementType Profile_1000 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Profile_1000"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Dependency_2014 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Dependency_2014"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Association_2015 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Association_2015"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Stereotype_1026 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Stereotype_1026"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Class_2008 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Class_2008"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Class_1031 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Metaclass_1031"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Comment_1002 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Comment_1002"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Constraint_1014 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Constraint_1014"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Model_2005 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Model_2005"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Profile_1030 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Profile_1030"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Package_2007 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Package_1004"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Enumeration_2006 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Enumeration_2006"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType PrimitiveType_2009 = getElementType("org.eclipse.papyrus.uml.diagram.profile.PrimitiveType_2009"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType DataType_2010 = getElementType("org.eclipse.papyrus.uml.diagram.profile.DataType_2010"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Diagram_2016 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Diagram_2016"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType PrimitiveType_3026 = getElementType("org.eclipse.papyrus.uml.diagram.profile.PrimitiveType_3026"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Operation_3019 = getElementType("org.eclipse.papyrus.uml.diagram.profile.DataTypeOperation_3019"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType EnumerationLiteral_1037 = getElementType("org.eclipse.papyrus.uml.diagram.profile.EnumerationLiteral_1037"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Property_3018 = getElementType("org.eclipse.papyrus.uml.diagram.profile.DataTypeProperty_3018"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Property_3002 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ClassProperty_3002"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Operation_3020 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ClassOperation_3020"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Stereotype_1023 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Stereotype_1023"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Class_3010 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Class_3010"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Class_3028 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Metaclass_3028"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Comment_1007 = getElementType("org.eclipse.papyrus.uml.diagram.profile.CommentCN_1007"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Model_1027 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Model_1027"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Profile_1024 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Profile_1024"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Package_1012 = getElementType("org.eclipse.papyrus.uml.diagram.profile.PackageCN_1012"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Constraint_1028 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Constraint_1028"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Enumeration_3025 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Enumeration_3025"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType DataType_3027 = getElementType("org.eclipse.papyrus.uml.diagram.profile.DataType_3027"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Extension_1013 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Extension_1013"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Association_4001 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Association_4001"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType ProfileApplication_1045 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ProfileApplication_1045"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Association_4019 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Association_4019"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Generalization_4002 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Generalization_4002"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Dependency_4008 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Dependency_4008"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType Dependency_4018 = getElementType("org.eclipse.papyrus.uml.diagram.profile.Dependency_4018"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType ElementImport_1064 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ElementImport_1064"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType PackageImport_1065 = getElementType("org.eclipse.papyrus.uml.diagram.profile.PackageImport_1065"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType CommentAnnotatedElement_1022 = getElementType("org.eclipse.papyrus.uml.diagram.profile.CommentAnnotatedElement_1022"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType ConstraintConstrainedElement_4014 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ConstraintConstrainedElement_4014"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final IElementType ConstraintContext_8500 = getElementType("org.eclipse.papyrus.uml.diagram.profile.ConstraintContext_8500"); //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static ImageDescriptor getImageDescriptor(ENamedElement element) {
+ return elementTypeImages.getImageDescriptor(element);
+ }
+
+ /**
+ * @generated
+ */
+ public static Image getImage(ENamedElement element) {
+ return elementTypeImages.getImage(element);
+ }
+
+ /**
+ * @generated
+ */
+ public static ImageDescriptor getImageDescriptor(IAdaptable hint) {
+ return getImageDescriptor(getElement(hint));
+ }
+
+ /**
+ * @generated
+ */
+ public static Image getImage(IAdaptable hint) {
+ return getImage(getElement(hint));
+ }
+
+ /**
+ * Returns 'type' of the ecore object associated with the hint.
+ *
+ * @generated
+ */
+ public static synchronized ENamedElement getElement(IAdaptable hint) {
+ Object type = hint.getAdapter(IElementType.class);
+ if (elements == null) {
+ elements = new IdentityHashMap<IElementType, ENamedElement>();
+ elements.put(Profile_1000, UMLPackage.eINSTANCE.getProfile());
+ elements.put(Dependency_2014, UMLPackage.eINSTANCE.getDependency());
+ elements.put(Association_2015, UMLPackage.eINSTANCE.getAssociation());
+ elements.put(Stereotype_1026, UMLPackage.eINSTANCE.getStereotype());
+ elements.put(Class_2008, UMLPackage.eINSTANCE.getClass_());
+ elements.put(Class_1031, UMLPackage.eINSTANCE.getClass_());
+ elements.put(Comment_1002, UMLPackage.eINSTANCE.getComment());
+ elements.put(Constraint_1014, UMLPackage.eINSTANCE.getConstraint());
+ elements.put(Model_2005, UMLPackage.eINSTANCE.getModel());
+ elements.put(Profile_1030, UMLPackage.eINSTANCE.getProfile());
+ elements.put(Package_2007, UMLPackage.eINSTANCE.getPackage());
+ elements.put(Enumeration_2006, UMLPackage.eINSTANCE.getEnumeration());
+ elements.put(PrimitiveType_2009, UMLPackage.eINSTANCE.getPrimitiveType());
+ elements.put(DataType_2010, UMLPackage.eINSTANCE.getDataType());
+ elements.put(Diagram_2016, NotationPackage.eINSTANCE.getDiagram());
+ elements.put(PrimitiveType_3026, UMLPackage.eINSTANCE.getPrimitiveType());
+ elements.put(Operation_3019, UMLPackage.eINSTANCE.getOperation());
+ elements.put(EnumerationLiteral_1037, UMLPackage.eINSTANCE.getEnumerationLiteral());
+ elements.put(Property_3018, UMLPackage.eINSTANCE.getProperty());
+ elements.put(Property_3002, UMLPackage.eINSTANCE.getProperty());
+ elements.put(Operation_3020, UMLPackage.eINSTANCE.getOperation());
+ elements.put(Stereotype_1023, UMLPackage.eINSTANCE.getStereotype());
+ elements.put(Class_3010, UMLPackage.eINSTANCE.getClass_());
+ elements.put(Class_3028, UMLPackage.eINSTANCE.getClass_());
+ elements.put(Comment_1007, UMLPackage.eINSTANCE.getComment());
+ elements.put(Model_1027, UMLPackage.eINSTANCE.getModel());
+ elements.put(Profile_1024, UMLPackage.eINSTANCE.getProfile());
+ elements.put(Package_1012, UMLPackage.eINSTANCE.getPackage());
+ elements.put(Constraint_1028, UMLPackage.eINSTANCE.getConstraint());
+ elements.put(Enumeration_3025, UMLPackage.eINSTANCE.getEnumeration());
+ elements.put(DataType_3027, UMLPackage.eINSTANCE.getDataType());
+ elements.put(Extension_1013, UMLPackage.eINSTANCE.getExtension());
+ elements.put(Association_4001, UMLPackage.eINSTANCE.getAssociation());
+ elements.put(ProfileApplication_1045, UMLPackage.eINSTANCE.getProfileApplication());
+ elements.put(Association_4019, UMLPackage.eINSTANCE.getAssociation());
+ elements.put(Generalization_4002, UMLPackage.eINSTANCE.getGeneralization());
+ elements.put(Dependency_4008, UMLPackage.eINSTANCE.getDependency());
+ elements.put(Dependency_4018, UMLPackage.eINSTANCE.getDependency());
+ elements.put(ElementImport_1064, UMLPackage.eINSTANCE.getElementImport());
+ elements.put(PackageImport_1065, UMLPackage.eINSTANCE.getPackageImport());
+ elements.put(CommentAnnotatedElement_1022, UMLPackage.eINSTANCE.getComment_AnnotatedElement());
+ elements.put(ConstraintConstrainedElement_4014, UMLPackage.eINSTANCE.getConstraint_ConstrainedElement());
+ elements.put(ConstraintContext_8500, UMLPackage.eINSTANCE.getConstraint_Context());
+ }
+ return (ENamedElement) elements.get(type);
+ }
+
+ /**
+ * @generated
+ */
+ private static IElementType getElementType(String id) {
+ return ElementTypeRegistry.getInstance().getType(id);
+ }
+
+ /**
+ * @generated
+ */
+ public static synchronized boolean isKnownElementType(IElementType elementType) {
+ if (KNOWN_ELEMENT_TYPES == null) {
+ KNOWN_ELEMENT_TYPES = new HashSet<IElementType>();
+ KNOWN_ELEMENT_TYPES.add(Profile_1000);
+ KNOWN_ELEMENT_TYPES.add(Dependency_2014);
+ KNOWN_ELEMENT_TYPES.add(Association_2015);
+ KNOWN_ELEMENT_TYPES.add(Stereotype_1026);
+ KNOWN_ELEMENT_TYPES.add(Class_2008);
+ KNOWN_ELEMENT_TYPES.add(Class_1031);
+ KNOWN_ELEMENT_TYPES.add(Comment_1002);
+ KNOWN_ELEMENT_TYPES.add(Constraint_1014);
+ KNOWN_ELEMENT_TYPES.add(Model_2005);
+ KNOWN_ELEMENT_TYPES.add(Profile_1030);
+ KNOWN_ELEMENT_TYPES.add(Package_2007);
+ KNOWN_ELEMENT_TYPES.add(Enumeration_2006);
+ KNOWN_ELEMENT_TYPES.add(PrimitiveType_2009);
+ KNOWN_ELEMENT_TYPES.add(DataType_2010);
+ KNOWN_ELEMENT_TYPES.add(Diagram_2016);
+ KNOWN_ELEMENT_TYPES.add(PrimitiveType_3026);
+ KNOWN_ELEMENT_TYPES.add(Operation_3019);
+ KNOWN_ELEMENT_TYPES.add(EnumerationLiteral_1037);
+ KNOWN_ELEMENT_TYPES.add(Property_3018);
+ KNOWN_ELEMENT_TYPES.add(Property_3002);
+ KNOWN_ELEMENT_TYPES.add(Operation_3020);
+ KNOWN_ELEMENT_TYPES.add(Stereotype_1023);
+ KNOWN_ELEMENT_TYPES.add(Class_3010);
+ KNOWN_ELEMENT_TYPES.add(Class_3028);
+ KNOWN_ELEMENT_TYPES.add(Comment_1007);
+ KNOWN_ELEMENT_TYPES.add(Model_1027);
+ KNOWN_ELEMENT_TYPES.add(Profile_1024);
+ KNOWN_ELEMENT_TYPES.add(Package_1012);
+ KNOWN_ELEMENT_TYPES.add(Constraint_1028);
+ KNOWN_ELEMENT_TYPES.add(Enumeration_3025);
+ KNOWN_ELEMENT_TYPES.add(DataType_3027);
+ KNOWN_ELEMENT_TYPES.add(Extension_1013);
+ KNOWN_ELEMENT_TYPES.add(Association_4001);
+ KNOWN_ELEMENT_TYPES.add(ProfileApplication_1045);
+ KNOWN_ELEMENT_TYPES.add(Association_4019);
+ KNOWN_ELEMENT_TYPES.add(Generalization_4002);
+ KNOWN_ELEMENT_TYPES.add(Dependency_4008);
+ KNOWN_ELEMENT_TYPES.add(Dependency_4018);
+ KNOWN_ELEMENT_TYPES.add(ElementImport_1064);
+ KNOWN_ELEMENT_TYPES.add(PackageImport_1065);
+ KNOWN_ELEMENT_TYPES.add(CommentAnnotatedElement_1022);
+ KNOWN_ELEMENT_TYPES.add(ConstraintConstrainedElement_4014);
+ KNOWN_ELEMENT_TYPES.add(ConstraintContext_8500);
+ }
+ return KNOWN_ELEMENT_TYPES.contains(elementType);
+ }
+
+ /**
+ * @generated
+ */
+ public static IElementType getElementType(int visualID) {
+ switch (visualID) {
+ case ProfileDiagramEditPart.VISUAL_ID:
+ return Profile_1000;
+ case DependencyNodeEditPart.VISUAL_ID:
+ return Dependency_2014;
+ case AssociationNodeEditPart.VISUAL_ID:
+ return Association_2015;
+ case StereotypeEditPart.VISUAL_ID:
+ return Stereotype_1026;
+ case ClassEditPart.VISUAL_ID:
+ return Class_2008;
+ case MetaclassEditPart.VISUAL_ID:
+ return Class_1031;
+ case CommentEditPart.VISUAL_ID:
+ return Comment_1002;
+ case ConstraintEditPart.VISUAL_ID:
+ return Constraint_1014;
+ case ModelEditPartTN.VISUAL_ID:
+ return Model_2005;
+ case ProfileEditPartTN.VISUAL_ID:
+ return Profile_1030;
+ case PackageEditPart.VISUAL_ID:
+ return Package_2007;
+ case EnumerationEditPart.VISUAL_ID:
+ return Enumeration_2006;
+ case PrimitiveTypeEditPart.VISUAL_ID:
+ return PrimitiveType_2009;
+ case DataTypeEditPart.VISUAL_ID:
+ return DataType_2010;
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ return Diagram_2016;
+ case PrimitiveTypeEditPartCN.VISUAL_ID:
+ return PrimitiveType_3026;
+ case DataTypeOperationEditPart.VISUAL_ID:
+ return Operation_3019;
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ return EnumerationLiteral_1037;
+ case DataTypePropertyEditPart.VISUAL_ID:
+ return Property_3018;
+ case ClassPropertyEditPart.VISUAL_ID:
+ return Property_3002;
+ case ClassOperationEditPart.VISUAL_ID:
+ return Operation_3020;
+ case StereotypeEditPartCN.VISUAL_ID:
+ return Stereotype_1023;
+ case ClassEditPartCN.VISUAL_ID:
+ return Class_3010;
+ case MetaclassEditPartCN.VISUAL_ID:
+ return Class_3028;
+ case CommentEditPartCN.VISUAL_ID:
+ return Comment_1007;
+ case ModelEditPartCN.VISUAL_ID:
+ return Model_1027;
+ case ProfileEditPartCN.VISUAL_ID:
+ return Profile_1024;
+ case PackageEditPartCN.VISUAL_ID:
+ return Package_1012;
+ case ConstraintEditPartCN.VISUAL_ID:
+ return Constraint_1028;
+ case EnumerationEditPartCN.VISUAL_ID:
+ return Enumeration_3025;
+ case DataTypeEditPartCN.VISUAL_ID:
+ return DataType_3027;
+ case ExtensionEditPart.VISUAL_ID:
+ return Extension_1013;
+ case AssociationEditPart.VISUAL_ID:
+ return Association_4001;
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return ProfileApplication_1045;
+ case AssociationBranchEditPart.VISUAL_ID:
+ return Association_4019;
+ case GeneralizationEditPart.VISUAL_ID:
+ return Generalization_4002;
+ case DependencyEditPart.VISUAL_ID:
+ return Dependency_4008;
+ case DependencyBranchEditPart.VISUAL_ID:
+ return Dependency_4018;
+ case ElementImportEditPart.VISUAL_ID:
+ return ElementImport_1064;
+ case PackageImportEditPart.VISUAL_ID:
+ return PackageImport_1065;
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return CommentAnnotatedElement_1022;
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return ConstraintConstrainedElement_4014;
+ case ContextLinkEditPart.VISUAL_ID:
+ return ConstraintContext_8500;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public static final DiagramElementTypes TYPED_INSTANCE = new DiagramElementTypes(elementTypeImages) {
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isKnownElementType(IElementType elementType) {
+ return org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes.isKnownElementType(elementType);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public IElementType getElementTypeForVisualId(int visualID) {
+ return org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes.getElementType(visualID);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public ENamedElement getDefiningNamedElement(IAdaptable elementTypeAdapter) {
+ return org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes.getElement(elementTypeAdapter);
+ }
+ };
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLMarkerNavigationProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLMarkerNavigationProvider.java
index e0ad3d8c938..475fc703522 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLMarkerNavigationProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLMarkerNavigationProvider.java
@@ -1,93 +1,96 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.providers;
-
-import java.util.Arrays;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
-import org.eclipse.gmf.runtime.emf.ui.providers.marker.AbstractModelMarkerNavigationProvider;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorUtil;
-
-/**
- * @generated
- */
-public class UMLMarkerNavigationProvider extends AbstractModelMarkerNavigationProvider {
-
- /**
- * @generated
- */
- public static final String MARKER_TYPE = UMLDiagramEditorPlugin.ID + ".diagnostic"; //$NON-NLS-1$
-
- /**
- * @generated
- */
- @Override
- protected void doGotoMarker(IMarker marker) {
- String elementId = marker.getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, null);
- if (elementId == null || !(getEditor() instanceof DiagramEditor)) {
- return;
- }
- DiagramEditor editor = (DiagramEditor) getEditor();
- Map<?, ?> editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
- EObject targetView = editor.getDiagram().eResource().getEObject(elementId);
- if (targetView == null) {
- return;
- }
- EditPart targetEditPart = (EditPart) editPartRegistry.get(targetView);
- if (targetEditPart != null) {
- UMLDiagramEditorUtil.selectElementsInDiagram(editor, Arrays.asList(new EditPart[] { targetEditPart }));
- }
- }
-
- /**
- * @generated
- */
- public static void deleteMarkers(IResource resource) {
- try {
- resource.deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_ZERO);
- } catch (CoreException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Failed to delete validation markers", e); //$NON-NLS-1$
- }
- }
-
- /**
- * @generated
- */
- public static IMarker addMarker(IFile file, String elementId, String location, String message, int statusSeverity) {
- IMarker marker = null;
- try {
- marker = file.createMarker(MARKER_TYPE);
- marker.setAttribute(IMarker.MESSAGE, message);
- marker.setAttribute(IMarker.LOCATION, location);
- marker.setAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, elementId);
- int markerSeverity = IMarker.SEVERITY_INFO;
- if (statusSeverity == IStatus.WARNING) {
- markerSeverity = IMarker.SEVERITY_WARNING;
- } else if (statusSeverity == IStatus.ERROR || statusSeverity == IStatus.CANCEL) {
- markerSeverity = IMarker.SEVERITY_ERROR;
- }
- marker.setAttribute(IMarker.SEVERITY, markerSeverity);
- } catch (CoreException e) {
- UMLDiagramEditorPlugin.getInstance().logError("Failed to create validation marker", e); //$NON-NLS-1$
- }
- return marker;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.providers;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.gmf.runtime.emf.ui.providers.marker.AbstractModelMarkerNavigationProvider;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorUtil;
+
+/**
+ * @generated
+ */
+public class UMLMarkerNavigationProvider extends AbstractModelMarkerNavigationProvider {
+
+ /**
+ * @generated
+ */
+ public static final String MARKER_TYPE = UMLDiagramEditorPlugin.ID + ".diagnostic"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void doGotoMarker(IMarker marker) {
+ String elementId = marker.getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, null);
+ if (elementId == null || !(getEditor() instanceof DiagramEditor)) {
+ return;
+ }
+ DiagramEditor editor =
+ (DiagramEditor) getEditor();
+ Map<?, ?> editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
+ EObject targetView = editor.getDiagram().eResource().getEObject(elementId);
+ if (targetView == null) {
+ return;
+ }
+ EditPart targetEditPart = (EditPart) editPartRegistry.get(targetView);
+ if (targetEditPart != null) {
+ UMLDiagramEditorUtil.selectElementsInDiagram(
+ editor, Arrays.asList(new EditPart[] { targetEditPart }));
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public static void deleteMarkers(IResource resource) {
+ try {
+ resource.deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_ZERO);
+ } catch (CoreException e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Failed to delete validation markers", e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public static IMarker addMarker(IFile file, String elementId, String location, String message, int statusSeverity) {
+ IMarker marker = null;
+ try {
+ marker = file.createMarker(MARKER_TYPE);
+ marker.setAttribute(IMarker.MESSAGE, message);
+ marker.setAttribute(IMarker.LOCATION, location);
+ marker.setAttribute(org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, elementId);
+ int markerSeverity = IMarker.SEVERITY_INFO;
+ if (statusSeverity == IStatus.WARNING) {
+ markerSeverity = IMarker.SEVERITY_WARNING;
+ } else if (statusSeverity == IStatus.ERROR ||
+ statusSeverity == IStatus.CANCEL) {
+ markerSeverity = IMarker.SEVERITY_ERROR;
+ }
+ marker.setAttribute(IMarker.SEVERITY, markerSeverity);
+ } catch (CoreException e) {
+ UMLDiagramEditorPlugin.getInstance().logError("Failed to create validation marker", e); //$NON-NLS-1$
+ }
+ return marker;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLParserProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLParserProvider.java
index 69a5cda72af..b4a4d8e5076 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLParserProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLParserProvider.java
@@ -1,999 +1,1073 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.providers;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.parser.CommentParser;
-import org.eclipse.papyrus.uml.diagram.common.parser.ConstraintParser;
-import org.eclipse.papyrus.uml.diagram.common.parser.packageimport.PackageImportVisibilityParser;
-import org.eclipse.papyrus.uml.diagram.common.parser.stereotype.AppliedStereotypeParser;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AppliedStereotypeElementImportEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchMultiplicityEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicitySourceEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicityTargetEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleSourceEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleTargetEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassNameEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentBodyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentBodyEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintBodyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintBodyEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintNameEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeNameEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DiagramNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportAliasEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationNameEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassNameEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelNameEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MultiDependencyLabelEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportAppliedStereotypeEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageNameEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeNameEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileNameEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileNameEditPartTN;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeNameEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeNameEditPartCN;
-import org.eclipse.papyrus.uml.diagram.profile.parsers.MessageFormatParser;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * @generated
- */
-public class UMLParserProvider extends AbstractProvider implements IParserProvider {
-
- /**
- * @generated
- */
- private IParser dependencyName_1Parser;
-
- /**
- * @generated
- */
- private IParser getDependencyName_1Parser() {
- if (dependencyName_1Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- dependencyName_1Parser = parser;
- }
- return dependencyName_1Parser;
- }
-
- /**
- * @generated
- */
- private IParser stereotypeName_1034Parser;
-
- /**
- * @generated
- */
- private IParser getStereotypeName_1034Parser() {
- if (stereotypeName_1034Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- stereotypeName_1034Parser = parser;
- }
- return stereotypeName_1034Parser;
- }
-
- /**
- * @generated
- */
- private IParser className_5029Parser;
-
- /**
- * @generated
- */
- private IParser getClassName_5029Parser() {
- if (className_5029Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- className_5029Parser = parser;
- }
- return className_5029Parser;
- }
-
- /**
- * @generated
- */
- private IParser className_1084Parser;
-
- /**
- * @generated
- */
- private IParser getClassName_1084Parser() {
- if (className_1084Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- className_1084Parser = parser;
- }
- return className_1084Parser;
- }
-
- /**
- * @generated
- */
- private CommentParser commentBody_3Parser;
-
- /**
- * @generated
- */
- private IParser getCommentBody_3Parser() {
- if (commentBody_3Parser == null) {
- commentBody_3Parser = new CommentParser();
- }
- return commentBody_3Parser;
- }
-
- /**
- * @generated
- */
- private IParser constraintName_1015Parser;
-
- /**
- * @generated
- */
- private IParser getConstraintName_1015Parser() {
- if (constraintName_1015Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- constraintName_1015Parser = parser;
- }
- return constraintName_1015Parser;
- }
-
- /**
- * @generated
- */
- private ConstraintParser constraintSpecification_5063Parser;
-
- /**
- * @generated
- */
- private IParser getConstraintSpecification_5063Parser() {
- if (constraintSpecification_5063Parser == null) {
- constraintSpecification_5063Parser = new ConstraintParser();
- }
- return constraintSpecification_5063Parser;
- }
-
- /**
- * @generated
- */
- private IParser modelName_5020Parser;
-
- /**
- * @generated
- */
- private IParser getModelName_5020Parser() {
- if (modelName_5020Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- modelName_5020Parser = parser;
- }
- return modelName_5020Parser;
- }
-
- /**
- * @generated
- */
- private IParser profileName_1047Parser;
-
- /**
- * @generated
- */
- private IParser getProfileName_1047Parser() {
- if (profileName_1047Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- profileName_1047Parser = parser;
- }
- return profileName_1047Parser;
- }
-
- /**
- * @generated
- */
- private IParser packageName_5026Parser;
-
- /**
- * @generated
- */
- private IParser getPackageName_5026Parser() {
- if (packageName_5026Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- packageName_5026Parser = parser;
- }
- return packageName_5026Parser;
- }
-
- /**
- * @generated
- */
- private IParser enumerationName_5023Parser;
-
- /**
- * @generated
- */
- private IParser getEnumerationName_5023Parser() {
- if (enumerationName_5023Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- enumerationName_5023Parser = parser;
- }
- return enumerationName_5023Parser;
- }
-
- /**
- * @generated
- */
- private IParser primitiveTypeName_5032Parser;
-
- /**
- * @generated
- */
- private IParser getPrimitiveTypeName_5032Parser() {
- if (primitiveTypeName_5032Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- primitiveTypeName_5032Parser = parser;
- }
- return primitiveTypeName_5032Parser;
- }
-
- /**
- * @generated
- */
- private IParser dataTypeName_5035Parser;
-
- /**
- * @generated
- */
- private IParser getDataTypeName_5035Parser() {
- if (dataTypeName_5035Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- dataTypeName_5035Parser = parser;
- }
- return dataTypeName_5035Parser;
- }
-
- /**
- * @generated
- */
- private IParser diagramName_2Parser;
-
- /**
- * @generated
- */
- private IParser getDiagramName_2Parser() {
- if (diagramName_2Parser == null) {
- EAttribute[] features = new EAttribute[] { NotationPackage.eINSTANCE.getDiagram_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- diagramName_2Parser = parser;
- }
- return diagramName_2Parser;
- }
-
- /**
- * @generated
- */
- private IParser primitiveTypeName_5058Parser;
-
- /**
- * @generated
- */
- private IParser getPrimitiveTypeName_5058Parser() {
- if (primitiveTypeName_5058Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- primitiveTypeName_5058Parser = parser;
- }
- return primitiveTypeName_5058Parser;
- }
-
- /**
- * @generated
- */
- private IParser operation_3019Parser;
-
- /**
- * @generated
- */
- private IParser getOperation_3019Parser() {
- if (operation_3019Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- operation_3019Parser = parser;
- }
- return operation_3019Parser;
- }
-
- /**
- * @generated
- */
- private IParser enumerationLiteral_1037Parser;
-
- /**
- * @generated
- */
- private IParser getEnumerationLiteral_1037Parser() {
- if (enumerationLiteral_1037Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- enumerationLiteral_1037Parser = parser;
- }
- return enumerationLiteral_1037Parser;
- }
-
- /**
- * @generated
- */
- private IParser property_3018Parser;
-
- /**
- * @generated
- */
- private IParser getProperty_3018Parser() {
- if (property_3018Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- property_3018Parser = parser;
- }
- return property_3018Parser;
- }
-
- /**
- * @generated
- */
- private IParser property_3002Parser;
-
- /**
- * @generated
- */
- private IParser getProperty_3002Parser() {
- if (property_3002Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- property_3002Parser = parser;
- }
- return property_3002Parser;
- }
-
- /**
- * @generated
- */
- private IParser operation_3020Parser;
-
- /**
- * @generated
- */
- private IParser getOperation_3020Parser() {
- if (operation_3020Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- operation_3020Parser = parser;
- }
- return operation_3020Parser;
- }
-
- /**
- * @generated
- */
- private IParser stereotypeName_1046Parser;
-
- /**
- * @generated
- */
- private IParser getStereotypeName_1046Parser() {
- if (stereotypeName_1046Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- stereotypeName_1046Parser = parser;
- }
- return stereotypeName_1046Parser;
- }
-
- /**
- * @generated
- */
- private IParser className_5014Parser;
-
- /**
- * @generated
- */
- private IParser getClassName_5014Parser() {
- if (className_5014Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- className_5014Parser = parser;
- }
- return className_5014Parser;
- }
-
- /**
- * @generated
- */
- private IParser className_5062Parser;
-
- /**
- * @generated
- */
- private IParser getClassName_5062Parser() {
- if (className_5062Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- className_5062Parser = parser;
- }
- return className_5062Parser;
- }
-
- /**
- * @generated
- */
- private CommentParser commentBody_1008Parser;
-
- /**
- * @generated
- */
- private IParser getCommentBody_1008Parser() {
- if (commentBody_1008Parser == null) {
- commentBody_1008Parser = new CommentParser();
- }
- return commentBody_1008Parser;
- }
-
- /**
- * @generated
- */
- private IParser modelName_1056Parser;
-
- /**
- * @generated
- */
- private IParser getModelName_1056Parser() {
- if (modelName_1056Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- modelName_1056Parser = parser;
- }
- return modelName_1056Parser;
- }
-
- /**
- * @generated
- */
- private IParser profileName_1050Parser;
-
- /**
- * @generated
- */
- private IParser getProfileName_1050Parser() {
- if (profileName_1050Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- profileName_1050Parser = parser;
- }
- return profileName_1050Parser;
- }
-
- /**
- * @generated
- */
- private IParser packageName_1010Parser;
-
- /**
- * @generated
- */
- private IParser getPackageName_1010Parser() {
- if (packageName_1010Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- packageName_1010Parser = parser;
- }
- return packageName_1010Parser;
- }
-
- /**
- * @generated
- */
- private IParser constraintName_1059Parser;
-
- /**
- * @generated
- */
- private IParser getConstraintName_1059Parser() {
- if (constraintName_1059Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- constraintName_1059Parser = parser;
- }
- return constraintName_1059Parser;
- }
-
- /**
- * @generated
- */
- private ConstraintParser constraintSpecification_5064Parser;
-
- /**
- * @generated
- */
- private IParser getConstraintSpecification_5064Parser() {
- if (constraintSpecification_5064Parser == null) {
- constraintSpecification_5064Parser = new ConstraintParser();
- }
- return constraintSpecification_5064Parser;
- }
-
- /**
- * @generated
- */
- private IParser enumerationName_5055Parser;
-
- /**
- * @generated
- */
- private IParser getEnumerationName_5055Parser() {
- if (enumerationName_5055Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- enumerationName_5055Parser = parser;
- }
- return enumerationName_5055Parser;
- }
-
- /**
- * @generated
- */
- private IParser dataTypeName_5061Parser;
-
- /**
- * @generated
- */
- private IParser getDataTypeName_5061Parser() {
- if (dataTypeName_5061Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- dataTypeName_5061Parser = parser;
- }
- return dataTypeName_5061Parser;
- }
-
- /**
- * @generated
- */
- private AppliedStereotypeParser associationName_6001Parser;
-
- /**
- * @generated
- */
- private IParser getAssociationName_6001Parser() {
- if (associationName_6001Parser == null) {
- associationName_6001Parser = new AppliedStereotypeParser();
- }
- return associationName_6001Parser;
- }
-
- /**
- * @generated
- */
- private IParser associationName_6002Parser;
-
- /**
- * @generated
- */
- private IParser getAssociationName_6002Parser() {
- if (associationName_6002Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- associationName_6002Parser = parser;
- }
- return associationName_6002Parser;
- }
-
- /**
- * @generated
- */
- private IParser associationName_6003Parser;
-
- /**
- * @generated
- */
- private IParser getAssociationName_6003Parser() {
- if (associationName_6003Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- parser.setViewPattern("srcRole{0}"); //$NON-NLS-1$
- parser.setEditorPattern("srcRole{0}"); //$NON-NLS-1$
- parser.setEditPattern("srcRole{0}"); //$NON-NLS-1$
- associationName_6003Parser = parser;
- }
- return associationName_6003Parser;
- }
-
- /**
- * @generated
- */
- private IParser associationName_6005Parser;
-
- /**
- * @generated
- */
- private IParser getAssociationName_6005Parser() {
- if (associationName_6005Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- parser.setViewPattern("targMul{0}"); //$NON-NLS-1$
- parser.setEditorPattern("targMul{0}"); //$NON-NLS-1$
- parser.setEditPattern("targMul{0}"); //$NON-NLS-1$
- associationName_6005Parser = parser;
- }
- return associationName_6005Parser;
- }
-
- /**
- * @generated
- */
- private IParser associationName_6033Parser;
-
- /**
- * @generated
- */
- private IParser getAssociationName_6033Parser() {
- if (associationName_6033Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- parser.setViewPattern("srcMul{0}"); //$NON-NLS-1$
- parser.setEditorPattern("srcMul{0}"); //$NON-NLS-1$
- parser.setEditPattern("srcMul{0}"); //$NON-NLS-1$
- associationName_6033Parser = parser;
- }
- return associationName_6033Parser;
- }
-
- /**
- * @generated
- */
- private IParser associationName_6034Parser;
-
- /**
- * @generated
- */
- private IParser getAssociationName_6034Parser() {
- if (associationName_6034Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- parser.setViewPattern("srcMul{0}"); //$NON-NLS-1$
- parser.setEditorPattern("srcMul{0}"); //$NON-NLS-1$
- parser.setEditPattern("srcMul{0}"); //$NON-NLS-1$
- associationName_6034Parser = parser;
- }
- return associationName_6034Parser;
- }
-
- /**
- * @generated
- */
- private IParser associationName_6035Parser;
-
- /**
- * @generated
- */
- private IParser getAssociationName_6035Parser() {
- if (associationName_6035Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- parser.setViewPattern("srcRole{0}"); //$NON-NLS-1$
- parser.setEditorPattern("srcRole{0}"); //$NON-NLS-1$
- parser.setEditPattern("srcRole{0}"); //$NON-NLS-1$
- associationName_6035Parser = parser;
- }
- return associationName_6035Parser;
- }
-
- /**
- * @generated
- */
- private IParser generalizationIsSubstitutable_6007Parser;
-
- /**
- * @generated
- */
- private IParser getGeneralizationIsSubstitutable_6007Parser() {
- if (generalizationIsSubstitutable_6007Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getGeneralization_IsSubstitutable() };
- MessageFormatParser parser = new MessageFormatParser(features);
- parser.setViewPattern("<<{0}>>"); //$NON-NLS-1$
- parser.setEditorPattern("<<{0}>>"); //$NON-NLS-1$
- parser.setEditPattern("<<{0}>>"); //$NON-NLS-1$
- generalizationIsSubstitutable_6007Parser = parser;
- }
- return generalizationIsSubstitutable_6007Parser;
- }
-
- /**
- * @generated
- */
- private IParser dependencyName_6026Parser;
-
- /**
- * @generated
- */
- private IParser getDependencyName_6026Parser() {
- if (dependencyName_6026Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() };
- MessageFormatParser parser = new MessageFormatParser(features);
- dependencyName_6026Parser = parser;
- }
- return dependencyName_6026Parser;
- }
-
- /**
- * @generated
- */
- private AppliedStereotypeParser dependencyName_6027Parser;
-
- /**
- * @generated
- */
- private IParser getDependencyName_6027Parser() {
- if (dependencyName_6027Parser == null) {
- dependencyName_6027Parser = new AppliedStereotypeParser();
- }
- return dependencyName_6027Parser;
- }
-
- /**
- * @generated
- */
- private IParser elementImportAlias_6020Parser;
-
- /**
- * @generated
- */
- private IParser getElementImportAlias_6020Parser() {
- if (elementImportAlias_6020Parser == null) {
- EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getElementImport_Alias() };
- MessageFormatParser parser = new MessageFormatParser(features);
- elementImportAlias_6020Parser = parser;
- }
- return elementImportAlias_6020Parser;
- }
-
- /**
- * @generated
- */
- private AppliedStereotypeParser elementImportAlias_6021Parser;
-
- /**
- * @generated
- */
- private IParser getElementImportAlias_6021Parser() {
- if (elementImportAlias_6021Parser == null) {
- elementImportAlias_6021Parser = new AppliedStereotypeParser();
- }
- return elementImportAlias_6021Parser;
- }
-
- /**
- * @generated
- */
- private PackageImportVisibilityParser packageImportVisibility_6022Parser;
-
- /**
- * @generated
- */
- private IParser getPackageImportVisibility_6022Parser() {
- if (packageImportVisibility_6022Parser == null) {
- packageImportVisibility_6022Parser = new PackageImportVisibilityParser();
- }
- return packageImportVisibility_6022Parser;
- }
-
- /**
- * @generated
- */
- protected IParser getParser(int visualID) {
- switch (visualID) {
- case MultiDependencyLabelEditPart.VISUAL_ID:
- return getDependencyName_1Parser();
- case StereotypeNameEditPart.VISUAL_ID:
- return getStereotypeName_1034Parser();
- case ClassNameEditPart.VISUAL_ID:
- return getClassName_5029Parser();
- case MetaclassNameEditPart.VISUAL_ID:
- return getClassName_1084Parser();
- case CommentBodyEditPart.VISUAL_ID:
- return getCommentBody_3Parser();
- case ConstraintNameEditPart.VISUAL_ID:
- return getConstraintName_1015Parser();
- case ConstraintBodyEditPart.VISUAL_ID:
- return getConstraintSpecification_5063Parser();
- case ModelNameEditPart.VISUAL_ID:
- return getModelName_5020Parser();
- case ProfileNameEditPartTN.VISUAL_ID:
- return getProfileName_1047Parser();
- case PackageNameEditPart.VISUAL_ID:
- return getPackageName_5026Parser();
- case EnumerationNameEditPart.VISUAL_ID:
- return getEnumerationName_5023Parser();
- case PrimitiveTypeNameEditPart.VISUAL_ID:
- return getPrimitiveTypeName_5032Parser();
- case DataTypeNameEditPart.VISUAL_ID:
- return getDataTypeName_5035Parser();
- case DiagramNameEditPart.VISUAL_ID:
- return getDiagramName_2Parser();
- case PrimitiveTypeNameEditPartCN.VISUAL_ID:
- return getPrimitiveTypeName_5058Parser();
- case DataTypeOperationEditPart.VISUAL_ID:
- return getOperation_3019Parser();
- case EnumerationLiteralEditPart.VISUAL_ID:
- return getEnumerationLiteral_1037Parser();
- case DataTypePropertyEditPart.VISUAL_ID:
- return getProperty_3018Parser();
- case ClassPropertyEditPart.VISUAL_ID:
- return getProperty_3002Parser();
- case ClassOperationEditPart.VISUAL_ID:
- return getOperation_3020Parser();
- case StereotypeNameEditPartCN.VISUAL_ID:
- return getStereotypeName_1046Parser();
- case ClassNameEditPartCN.VISUAL_ID:
- return getClassName_5014Parser();
- case MetaclassNameEditPartCN.VISUAL_ID:
- return getClassName_5062Parser();
- case CommentBodyEditPartCN.VISUAL_ID:
- return getCommentBody_1008Parser();
- case ModelNameEditPartCN.VISUAL_ID:
- return getModelName_1056Parser();
- case ProfileNameEditPartCN.VISUAL_ID:
- return getProfileName_1050Parser();
- case PackageNameEditPartCN.VISUAL_ID:
- return getPackageName_1010Parser();
- case ConstraintNameEditPartCN.VISUAL_ID:
- return getConstraintName_1059Parser();
- case ConstraintBodyEditPartCN.VISUAL_ID:
- return getConstraintSpecification_5064Parser();
- case EnumerationNameEditPartCN.VISUAL_ID:
- return getEnumerationName_5055Parser();
- case DataTypeNameEditPartCN.VISUAL_ID:
- return getDataTypeName_5061Parser();
- case AssociationAppliedStereotypeEditPart.VISUAL_ID:
- return getAssociationName_6001Parser();
- case AssociationNameEditPart.VISUAL_ID:
- return getAssociationName_6002Parser();
- case AssociationRoleTargetEditPart.VISUAL_ID:
- return getAssociationName_6003Parser();
- case AssociationRoleSourceEditPart.VISUAL_ID:
- return getAssociationName_6005Parser();
- case AssociationMultiplicitySourceEditPart.VISUAL_ID:
- return getAssociationName_6033Parser();
- case AssociationMultiplicityTargetEditPart.VISUAL_ID:
- return getAssociationName_6034Parser();
- case AssociationBranchMultiplicityEditPart.VISUAL_ID:
- return getAssociationName_6035Parser();
- case GeneralizationAppliedStereotypeEditPart.VISUAL_ID:
- return getGeneralizationIsSubstitutable_6007Parser();
- case DependencyNameEditPart.VISUAL_ID:
- return getDependencyName_6026Parser();
- case DependencyAppliedStereotypeEditPart.VISUAL_ID:
- return getDependencyName_6027Parser();
- case ElementImportAliasEditPart.VISUAL_ID:
- return getElementImportAlias_6020Parser();
- case AppliedStereotypeElementImportEditPart.VISUAL_ID:
- return getElementImportAlias_6021Parser();
- case PackageImportAppliedStereotypeEditPart.VISUAL_ID:
- return getPackageImportVisibility_6022Parser();
- }
- return null;
- }
-
- /**
- * Utility method that consults ParserService
- *
- * @generated
- */
- public static IParser getParser(IElementType type, EObject object, String parserHint) {
- return ParserService.getInstance().getParser(new HintAdapter(type, object, parserHint));
- }
-
- /**
- * @generated
- */
- public IParser getParser(IAdaptable hint) {
- String vid = (String) hint.getAdapter(String.class);
- if (vid != null) {
- return getParser(UMLVisualIDRegistry.getVisualID(vid));
- }
- View view = (View) hint.getAdapter(View.class);
- if (view != null) {
- return getParser(UMLVisualIDRegistry.getVisualID(view));
- }
- return null;
- }
-
- /**
- * @generated
- */
- public boolean provides(IOperation operation) {
- if (operation instanceof GetParserOperation) {
- IAdaptable hint = ((GetParserOperation) operation).getHint();
- if (UMLElementTypes.getElement(hint) == null) {
- return false;
- }
- return getParser(hint) != null;
- }
- return false;
- }
-
- /**
- * @generated
- */
- private static class HintAdapter extends ParserHintAdapter {
-
- /**
- * @generated
- */
- private final IElementType elementType;
-
- /**
- * @generated
- */
- public HintAdapter(IElementType type, EObject object, String parserHint) {
- super(object, parserHint);
- assert type != null;
- elementType = type;
- }
-
- /**
- * @generated
- */
- @Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- if (IElementType.class.equals(adapter)) {
- return elementType;
- }
- return super.getAdapter(adapter);
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.providers;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.parser.CommentParser;
+import org.eclipse.papyrus.uml.diagram.common.parser.ConstraintParser;
+import org.eclipse.papyrus.uml.diagram.common.parser.packageimport.PackageImportVisibilityParser;
+import org.eclipse.papyrus.uml.diagram.common.parser.stereotype.AppliedStereotypeParser;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AppliedStereotypeElementImportEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationAppliedStereotypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationBranchMultiplicityEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicitySourceEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationMultiplicityTargetEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleSourceEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationRoleTargetEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ClassPropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentBodyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.CommentBodyEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintBodyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintBodyEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ConstraintNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypeOperationEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DataTypePropertyEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyAppliedStereotypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DependencyNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.DiagramNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ElementImportAliasEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationLiteralEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.EnumerationNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.GeneralizationAppliedStereotypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MetaclassNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ModelNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.MultiDependencyLabelEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageImportAppliedStereotypeEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PackageNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.PrimitiveTypeNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileNameEditPartTN;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeNameEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.StereotypeNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.profile.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @generated
+ */
+public class UMLParserProvider extends AbstractProvider implements IParserProvider {
+
+ /**
+ * @generated
+ */
+ private IParser dependencyName_1Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getDependencyName_1Parser() {
+ if (dependencyName_1Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ dependencyName_1Parser = parser;
+ }
+ return dependencyName_1Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser stereotypeName_1034Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getStereotypeName_1034Parser() {
+ if (stereotypeName_1034Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ stereotypeName_1034Parser = parser;
+ }
+ return stereotypeName_1034Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser className_5029Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getClassName_5029Parser() {
+ if (className_5029Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ className_5029Parser = parser;
+ }
+ return className_5029Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser className_1084Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getClassName_1084Parser() {
+ if (className_1084Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ className_1084Parser = parser;
+ }
+ return className_1084Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private CommentParser commentBody_3Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getCommentBody_3Parser() {
+ if (commentBody_3Parser == null) {
+ commentBody_3Parser = new CommentParser();
+ }
+ return commentBody_3Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser constraintName_1015Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getConstraintName_1015Parser() {
+ if (constraintName_1015Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ constraintName_1015Parser = parser;
+ }
+ return constraintName_1015Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private ConstraintParser constraintSpecification_5063Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getConstraintSpecification_5063Parser() {
+ if (constraintSpecification_5063Parser == null) {
+ constraintSpecification_5063Parser = new ConstraintParser();
+ }
+ return constraintSpecification_5063Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser modelName_5020Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getModelName_5020Parser() {
+ if (modelName_5020Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ modelName_5020Parser = parser;
+ }
+ return modelName_5020Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser profileName_1047Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getProfileName_1047Parser() {
+ if (profileName_1047Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ profileName_1047Parser = parser;
+ }
+ return profileName_1047Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser packageName_5026Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getPackageName_5026Parser() {
+ if (packageName_5026Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ packageName_5026Parser = parser;
+ }
+ return packageName_5026Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser enumerationName_5023Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getEnumerationName_5023Parser() {
+ if (enumerationName_5023Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ enumerationName_5023Parser = parser;
+ }
+ return enumerationName_5023Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser primitiveTypeName_5032Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getPrimitiveTypeName_5032Parser() {
+ if (primitiveTypeName_5032Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ primitiveTypeName_5032Parser = parser;
+ }
+ return primitiveTypeName_5032Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser dataTypeName_5035Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getDataTypeName_5035Parser() {
+ if (dataTypeName_5035Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ dataTypeName_5035Parser = parser;
+ }
+ return dataTypeName_5035Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser diagramName_2Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getDiagramName_2Parser() {
+ if (diagramName_2Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ NotationPackage.eINSTANCE.getDiagram_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ diagramName_2Parser = parser;
+ }
+ return diagramName_2Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser primitiveTypeName_5058Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getPrimitiveTypeName_5058Parser() {
+ if (primitiveTypeName_5058Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ primitiveTypeName_5058Parser = parser;
+ }
+ return primitiveTypeName_5058Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser operation_3019Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getOperation_3019Parser() {
+ if (operation_3019Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ operation_3019Parser = parser;
+ }
+ return operation_3019Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser enumerationLiteral_1037Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getEnumerationLiteral_1037Parser() {
+ if (enumerationLiteral_1037Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ enumerationLiteral_1037Parser = parser;
+ }
+ return enumerationLiteral_1037Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser property_3018Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getProperty_3018Parser() {
+ if (property_3018Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ property_3018Parser = parser;
+ }
+ return property_3018Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser property_3002Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getProperty_3002Parser() {
+ if (property_3002Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ property_3002Parser = parser;
+ }
+ return property_3002Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser operation_3020Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getOperation_3020Parser() {
+ if (operation_3020Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ operation_3020Parser = parser;
+ }
+ return operation_3020Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser stereotypeName_1046Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getStereotypeName_1046Parser() {
+ if (stereotypeName_1046Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ stereotypeName_1046Parser = parser;
+ }
+ return stereotypeName_1046Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser className_5014Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getClassName_5014Parser() {
+ if (className_5014Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ className_5014Parser = parser;
+ }
+ return className_5014Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser className_5062Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getClassName_5062Parser() {
+ if (className_5062Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ className_5062Parser = parser;
+ }
+ return className_5062Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private CommentParser commentBody_1008Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getCommentBody_1008Parser() {
+ if (commentBody_1008Parser == null) {
+ commentBody_1008Parser = new CommentParser();
+ }
+ return commentBody_1008Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser modelName_1056Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getModelName_1056Parser() {
+ if (modelName_1056Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ modelName_1056Parser = parser;
+ }
+ return modelName_1056Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser profileName_1050Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getProfileName_1050Parser() {
+ if (profileName_1050Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ profileName_1050Parser = parser;
+ }
+ return profileName_1050Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser packageName_1010Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getPackageName_1010Parser() {
+ if (packageName_1010Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ packageName_1010Parser = parser;
+ }
+ return packageName_1010Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser constraintName_1059Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getConstraintName_1059Parser() {
+ if (constraintName_1059Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ constraintName_1059Parser = parser;
+ }
+ return constraintName_1059Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private ConstraintParser constraintSpecification_5064Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getConstraintSpecification_5064Parser() {
+ if (constraintSpecification_5064Parser == null) {
+ constraintSpecification_5064Parser = new ConstraintParser();
+ }
+ return constraintSpecification_5064Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser enumerationName_5055Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getEnumerationName_5055Parser() {
+ if (enumerationName_5055Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ enumerationName_5055Parser = parser;
+ }
+ return enumerationName_5055Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser dataTypeName_5061Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getDataTypeName_5061Parser() {
+ if (dataTypeName_5061Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ dataTypeName_5061Parser = parser;
+ }
+ return dataTypeName_5061Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private AppliedStereotypeParser associationName_6001Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getAssociationName_6001Parser() {
+ if (associationName_6001Parser == null) {
+ associationName_6001Parser = new AppliedStereotypeParser();
+ }
+ return associationName_6001Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser associationName_6002Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getAssociationName_6002Parser() {
+ if (associationName_6002Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ associationName_6002Parser = parser;
+ }
+ return associationName_6002Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser associationName_6003Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getAssociationName_6003Parser() {
+ if (associationName_6003Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ parser.setViewPattern("srcRole{0}"); //$NON-NLS-1$
+ parser.setEditorPattern("srcRole{0}"); //$NON-NLS-1$
+ parser.setEditPattern("srcRole{0}"); //$NON-NLS-1$
+ associationName_6003Parser = parser;
+ }
+ return associationName_6003Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser associationName_6005Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getAssociationName_6005Parser() {
+ if (associationName_6005Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ parser.setViewPattern("targMul{0}"); //$NON-NLS-1$
+ parser.setEditorPattern("targMul{0}"); //$NON-NLS-1$
+ parser.setEditPattern("targMul{0}"); //$NON-NLS-1$
+ associationName_6005Parser = parser;
+ }
+ return associationName_6005Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser associationName_6033Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getAssociationName_6033Parser() {
+ if (associationName_6033Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ parser.setViewPattern("srcMul{0}"); //$NON-NLS-1$
+ parser.setEditorPattern("srcMul{0}"); //$NON-NLS-1$
+ parser.setEditPattern("srcMul{0}"); //$NON-NLS-1$
+ associationName_6033Parser = parser;
+ }
+ return associationName_6033Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser associationName_6034Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getAssociationName_6034Parser() {
+ if (associationName_6034Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ parser.setViewPattern("srcMul{0}"); //$NON-NLS-1$
+ parser.setEditorPattern("srcMul{0}"); //$NON-NLS-1$
+ parser.setEditPattern("srcMul{0}"); //$NON-NLS-1$
+ associationName_6034Parser = parser;
+ }
+ return associationName_6034Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser associationName_6035Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getAssociationName_6035Parser() {
+ if (associationName_6035Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ parser.setViewPattern("srcRole{0}"); //$NON-NLS-1$
+ parser.setEditorPattern("srcRole{0}"); //$NON-NLS-1$
+ parser.setEditPattern("srcRole{0}"); //$NON-NLS-1$
+ associationName_6035Parser = parser;
+ }
+ return associationName_6035Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser generalizationIsSubstitutable_6007Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getGeneralizationIsSubstitutable_6007Parser() {
+ if (generalizationIsSubstitutable_6007Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getGeneralization_IsSubstitutable()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ parser.setViewPattern("<<{0}>>"); //$NON-NLS-1$
+ parser.setEditorPattern("<<{0}>>"); //$NON-NLS-1$
+ parser.setEditPattern("<<{0}>>"); //$NON-NLS-1$
+ generalizationIsSubstitutable_6007Parser = parser;
+ }
+ return generalizationIsSubstitutable_6007Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser dependencyName_6026Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getDependencyName_6026Parser() {
+ if (dependencyName_6026Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getNamedElement_Name()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ dependencyName_6026Parser = parser;
+ }
+ return dependencyName_6026Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private AppliedStereotypeParser dependencyName_6027Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getDependencyName_6027Parser() {
+ if (dependencyName_6027Parser == null) {
+ dependencyName_6027Parser = new AppliedStereotypeParser();
+ }
+ return dependencyName_6027Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private IParser elementImportAlias_6020Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getElementImportAlias_6020Parser() {
+ if (elementImportAlias_6020Parser == null) {
+ EAttribute[] features = new EAttribute[] {
+ UMLPackage.eINSTANCE.getElementImport_Alias()
+ };
+ MessageFormatParser parser = new MessageFormatParser(features);
+ elementImportAlias_6020Parser = parser;
+ }
+ return elementImportAlias_6020Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private AppliedStereotypeParser elementImportAlias_6021Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getElementImportAlias_6021Parser() {
+ if (elementImportAlias_6021Parser == null) {
+ elementImportAlias_6021Parser = new AppliedStereotypeParser();
+ }
+ return elementImportAlias_6021Parser;
+ }
+
+ /**
+ * @generated
+ */
+ private PackageImportVisibilityParser packageImportVisibility_6022Parser;
+
+ /**
+ * @generated
+ */
+ private IParser getPackageImportVisibility_6022Parser() {
+ if (packageImportVisibility_6022Parser == null) {
+ packageImportVisibility_6022Parser = new PackageImportVisibilityParser();
+ }
+ return packageImportVisibility_6022Parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected IParser getParser(int visualID) {
+ switch (visualID) {
+ case MultiDependencyLabelEditPart.VISUAL_ID:
+ return getDependencyName_1Parser();
+ case StereotypeNameEditPart.VISUAL_ID:
+ return getStereotypeName_1034Parser();
+ case ClassNameEditPart.VISUAL_ID:
+ return getClassName_5029Parser();
+ case MetaclassNameEditPart.VISUAL_ID:
+ return getClassName_1084Parser();
+ case CommentBodyEditPart.VISUAL_ID:
+ return getCommentBody_3Parser();
+ case ConstraintNameEditPart.VISUAL_ID:
+ return getConstraintName_1015Parser();
+ case ConstraintBodyEditPart.VISUAL_ID:
+ return getConstraintSpecification_5063Parser();
+ case ModelNameEditPart.VISUAL_ID:
+ return getModelName_5020Parser();
+ case ProfileNameEditPartTN.VISUAL_ID:
+ return getProfileName_1047Parser();
+ case PackageNameEditPart.VISUAL_ID:
+ return getPackageName_5026Parser();
+ case EnumerationNameEditPart.VISUAL_ID:
+ return getEnumerationName_5023Parser();
+ case PrimitiveTypeNameEditPart.VISUAL_ID:
+ return getPrimitiveTypeName_5032Parser();
+ case DataTypeNameEditPart.VISUAL_ID:
+ return getDataTypeName_5035Parser();
+ case DiagramNameEditPart.VISUAL_ID:
+ return getDiagramName_2Parser();
+ case PrimitiveTypeNameEditPartCN.VISUAL_ID:
+ return getPrimitiveTypeName_5058Parser();
+ case DataTypeOperationEditPart.VISUAL_ID:
+ return getOperation_3019Parser();
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ return getEnumerationLiteral_1037Parser();
+ case DataTypePropertyEditPart.VISUAL_ID:
+ return getProperty_3018Parser();
+ case ClassPropertyEditPart.VISUAL_ID:
+ return getProperty_3002Parser();
+ case ClassOperationEditPart.VISUAL_ID:
+ return getOperation_3020Parser();
+ case StereotypeNameEditPartCN.VISUAL_ID:
+ return getStereotypeName_1046Parser();
+ case ClassNameEditPartCN.VISUAL_ID:
+ return getClassName_5014Parser();
+ case MetaclassNameEditPartCN.VISUAL_ID:
+ return getClassName_5062Parser();
+ case CommentBodyEditPartCN.VISUAL_ID:
+ return getCommentBody_1008Parser();
+ case ModelNameEditPartCN.VISUAL_ID:
+ return getModelName_1056Parser();
+ case ProfileNameEditPartCN.VISUAL_ID:
+ return getProfileName_1050Parser();
+ case PackageNameEditPartCN.VISUAL_ID:
+ return getPackageName_1010Parser();
+ case ConstraintNameEditPartCN.VISUAL_ID:
+ return getConstraintName_1059Parser();
+ case ConstraintBodyEditPartCN.VISUAL_ID:
+ return getConstraintSpecification_5064Parser();
+ case EnumerationNameEditPartCN.VISUAL_ID:
+ return getEnumerationName_5055Parser();
+ case DataTypeNameEditPartCN.VISUAL_ID:
+ return getDataTypeName_5061Parser();
+ case AssociationAppliedStereotypeEditPart.VISUAL_ID:
+ return getAssociationName_6001Parser();
+ case AssociationNameEditPart.VISUAL_ID:
+ return getAssociationName_6002Parser();
+ case AssociationRoleTargetEditPart.VISUAL_ID:
+ return getAssociationName_6003Parser();
+ case AssociationRoleSourceEditPart.VISUAL_ID:
+ return getAssociationName_6005Parser();
+ case AssociationMultiplicitySourceEditPart.VISUAL_ID:
+ return getAssociationName_6033Parser();
+ case AssociationMultiplicityTargetEditPart.VISUAL_ID:
+ return getAssociationName_6034Parser();
+ case AssociationBranchMultiplicityEditPart.VISUAL_ID:
+ return getAssociationName_6035Parser();
+ case GeneralizationAppliedStereotypeEditPart.VISUAL_ID:
+ return getGeneralizationIsSubstitutable_6007Parser();
+ case DependencyNameEditPart.VISUAL_ID:
+ return getDependencyName_6026Parser();
+ case DependencyAppliedStereotypeEditPart.VISUAL_ID:
+ return getDependencyName_6027Parser();
+ case ElementImportAliasEditPart.VISUAL_ID:
+ return getElementImportAlias_6020Parser();
+ case AppliedStereotypeElementImportEditPart.VISUAL_ID:
+ return getElementImportAlias_6021Parser();
+ case PackageImportAppliedStereotypeEditPart.VISUAL_ID:
+ return getPackageImportVisibility_6022Parser();
+ }
+ return null;
+ }
+
+ /**
+ * Utility method that consults ParserService
+ *
+ * @generated
+ */
+ public static IParser getParser(IElementType type, EObject object, String parserHint) {
+ return ParserService.getInstance().getParser(new HintAdapter(type, object, parserHint));
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser(IAdaptable hint) {
+ String vid = (String) hint.getAdapter(String.class);
+ if (vid != null) {
+ return getParser(UMLVisualIDRegistry.getVisualID(vid));
+ }
+ View view =
+ (View) hint.getAdapter(View.class);
+ if (view != null) {
+ return getParser(UMLVisualIDRegistry.getVisualID(view));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean provides(IOperation operation) {
+ if (operation instanceof GetParserOperation) {
+ IAdaptable hint =
+ ((GetParserOperation) operation).getHint();
+ if (UMLElementTypes.getElement(hint) == null) {
+ return false;
+ }
+ return getParser(hint) != null;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ private static class HintAdapter extends ParserHintAdapter {
+
+ /**
+ * @generated
+ */
+ private final IElementType elementType;
+
+ /**
+ * @generated
+ */
+ public HintAdapter(IElementType type, EObject object, String parserHint) {
+ super(object, parserHint);
+ assert type != null;
+ elementType = type;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ if (IElementType.class.equals(adapter)) {
+ return elementType;
+ }
+ return super.getAdapter(adapter);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLValidationDecoratorProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLValidationDecoratorProvider.java
index ed5d0849155..438ae30e73a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLValidationDecoratorProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLValidationDecoratorProvider.java
@@ -1,71 +1,74 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.providers;
-
-import org.eclipse.gef.EditDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.editparts.AbstractConnectionEditPart;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain;
-import org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider;
-import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.providers.ValidationDecoratorProvider;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditor;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-
-/**
- * @generated
- */
-public class UMLValidationDecoratorProvider extends ValidationDecoratorProvider implements IDecoratorProvider {
-
- /**
- * @generated
- */
- @Override
- public void createDecorators(IDecoratorTarget decoratorTarget) {
- EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class);
- if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) {
- Object model = editPart.getModel();
- if ((model instanceof View)) {
- View view = (View) model;
- if (!(view instanceof Edge) && !view.isSetElement()) {
- return;
- }
- }
- EditDomain ed = editPart.getViewer().getEditDomain();
- if (!(ed instanceof DiagramEditDomain)) {
- return;
- }
- if (((DiagramEditDomain) ed).getEditorPart() instanceof UMLDiagramEditor) {
- decoratorTarget.installDecorator(KEY, new StatusDecorator(decoratorTarget));
- }
- }
- }
-
- /**
- * @generated
- */
- @Override
- public boolean provides(IOperation operation) {
- if (!(operation instanceof CreateDecoratorsOperation)) {
- return false;
- }
- IDecoratorTarget decoratorTarget = ((CreateDecoratorsOperation) operation).getDecoratorTarget();
- View view = (View) decoratorTarget.getAdapter(View.class);
- return view != null && ProfileDiagramEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(view));
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.providers;
+
+import org.eclipse.gef.EditDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.providers.ValidationDecoratorProvider;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.ProfileDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditor;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+
+/**
+ * @generated
+ */
+public class UMLValidationDecoratorProvider extends ValidationDecoratorProvider implements IDecoratorProvider {
+
+ /**
+ * @generated
+ */
+ @Override
+ public void createDecorators(IDecoratorTarget decoratorTarget) {
+ EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class);
+ if (editPart instanceof GraphicalEditPart ||
+ editPart instanceof AbstractConnectionEditPart) {
+ Object model = editPart.getModel();
+ if ((model instanceof View)) {
+ View view = (View) model;
+ if (!(view instanceof Edge) && !view.isSetElement()) {
+ return;
+ }
+ }
+ EditDomain ed = editPart.getViewer().getEditDomain();
+ if (!(ed instanceof DiagramEditDomain)) {
+ return;
+ }
+ if (((DiagramEditDomain) ed).getEditorPart() instanceof UMLDiagramEditor) {
+ decoratorTarget.installDecorator(KEY, new StatusDecorator(decoratorTarget));
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean provides(IOperation operation) {
+ if (!(operation instanceof CreateDecoratorsOperation)) {
+ return false;
+ }
+ IDecoratorTarget decoratorTarget =
+ ((CreateDecoratorsOperation) operation).getDecoratorTarget();
+ View view = (View) decoratorTarget.getAdapter(
+ View.class);
+ return view != null && ProfileDiagramEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(view));
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLViewProvider.java
index 91bb589596b..a6febd83f04 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/providers/UMLViewProvider.java
@@ -1,1402 +1,1401 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
-import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation;
-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.notation.Connector;
-import org.eclipse.gmf.runtime.notation.DecorationNode;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.FillStyle;
-import org.eclipse.gmf.runtime.notation.FontStyle;
-import org.eclipse.gmf.runtime.notation.Location;
-import org.eclipse.gmf.runtime.notation.MeasurementUnit;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
-import org.eclipse.gmf.runtime.notation.Shape;
-import org.eclipse.gmf.runtime.notation.TitleStyle;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
-import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
-import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
-import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
-import org.eclipse.papyrus.uml.diagram.profile.edit.parts.*;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.FontData;
-
-/**
- * @generated
- */
-public class UMLViewProvider extends AbstractProvider implements IViewProvider {
-
- /**
- * @generated
- */
- public final boolean provides(IOperation operation) {
- if (operation instanceof CreateViewForKindOperation) {
- return provides((CreateViewForKindOperation) operation);
- }
- assert operation instanceof CreateViewOperation;
- if (operation instanceof CreateDiagramViewOperation) {
- return provides((CreateDiagramViewOperation) operation);
- } else if (operation instanceof CreateEdgeViewOperation) {
- return provides((CreateEdgeViewOperation) operation);
- } else if (operation instanceof CreateNodeViewOperation) {
- return provides((CreateNodeViewOperation) operation);
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean provides(CreateViewForKindOperation op) {
- /*
- * if (op.getViewKind() == Node.class)
- * return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
- * if (op.getViewKind() == Edge.class)
- * return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
- */
- // check Diagram Type should be the class diagram
- String modelID = UMLVisualIDRegistry.getModelID(op.getContainerView());
- if (!getDiagramProvidedId().equals(modelID)) {
- return false;
- }
- int visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint());
- if (Node.class.isAssignableFrom(op.getViewKind())) {
- return UMLVisualIDRegistry.canCreateNode(op.getContainerView(), visualID);
- }
- return true;
- }
-
- /**
- * @generated
- */
- protected String getDiagramProvidedId() {
- /*
- * Indicates for which diagram this provider works for.
- * <p>
- * This method can be overloaded when diagram editor inherits from another one, but should never be <code>null</code>
- * </p>
- *
- * @return the unique identifier of the diagram for which views are provided.
- */
- return ProfileDiagramEditPart.MODEL_ID;
- }
-
- /**
- * @generated
- */
- protected boolean provides(CreateDiagramViewOperation op) {
- return ProfileDiagramEditPart.MODEL_ID.equals(op.getSemanticHint()) && UMLVisualIDRegistry.getDiagramVisualID(getSemanticElement(op.getSemanticAdapter())) != -1;
- }
-
- /**
- * @generated
- */
- protected boolean provides(CreateNodeViewOperation op) {
- if (op.getContainerView() == null) {
- return false;
- }
- IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
- EObject domainElement = getSemanticElement(op.getSemanticAdapter());
- int visualID;
- if (op.getSemanticHint() == null) {
- // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
- // In this situation there should be NO elementType, visualID will be determined
- // by VisualIDRegistry.getNodeVisualID() for domainElement.
- if (elementType != null || domainElement == null) {
- return false;
- }
- visualID = UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement);
- } else {
- visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint());
- if (elementType != null) {
- if (elementType instanceof IExtendedHintedElementType) {
- if (domainElement != null) {
- if (!UMLVisualIDRegistry.checkNodeVisualID(op.getContainerView(), domainElement, visualID)) {
- return false;
- }
- }
- } else {
- if (!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) {
- return false; // foreign element type
- }
- }
- String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
- if (!op.getSemanticHint().equals(elementTypeHint)) {
- return false; // if semantic hint is specified it should be the same as in element type
- }
- if (domainElement != null && visualID != UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement)) {
- return false; // visual id for node EClass should match visual id from element type
- }
- } else {
- if (!ProfileDiagramEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(op.getContainerView()))) {
- return false; // foreign diagram
- }
- switch (visualID) {
- case DependencyNodeEditPart.VISUAL_ID:
- case AssociationNodeEditPart.VISUAL_ID:
- case StereotypeEditPart.VISUAL_ID:
- case ClassEditPart.VISUAL_ID:
- case CommentEditPart.VISUAL_ID:
- case ConstraintEditPart.VISUAL_ID:
- case ModelEditPartTN.VISUAL_ID:
- case ProfileEditPartTN.VISUAL_ID:
- case PackageEditPart.VISUAL_ID:
- case EnumerationEditPart.VISUAL_ID:
- case DataTypeEditPart.VISUAL_ID:
- case ShortCutDiagramEditPart.VISUAL_ID:
- case PrimitiveTypeEditPartCN.VISUAL_ID:
- case DataTypeOperationEditPart.VISUAL_ID:
- case EnumerationLiteralEditPart.VISUAL_ID:
- case DataTypePropertyEditPart.VISUAL_ID:
- case ClassPropertyEditPart.VISUAL_ID:
- case ClassOperationEditPart.VISUAL_ID:
- case StereotypeEditPartCN.VISUAL_ID:
- case MetaclassEditPartCN.VISUAL_ID:
- case CommentEditPartCN.VISUAL_ID:
- case PackageEditPartCN.VISUAL_ID:
- case ConstraintEditPartCN.VISUAL_ID:
- case MetaclassEditPart.VISUAL_ID:
- case PrimitiveTypeEditPart.VISUAL_ID:
- case ClassEditPartCN.VISUAL_ID:
- case ModelEditPartCN.VISUAL_ID:
- case ProfileEditPartCN.VISUAL_ID:
- case EnumerationEditPartCN.VISUAL_ID:
- case DataTypeEditPartCN.VISUAL_ID:
- if (domainElement == null || visualID != UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement)) {
- return false; // visual id in semantic hint should match visual id for domain element
- }
- break;
- default:
- return false;
- }
- }
- }
- return DependencyNodeEditPart.VISUAL_ID == visualID || AssociationNodeEditPart.VISUAL_ID == visualID || StereotypeEditPart.VISUAL_ID == visualID || ClassEditPart.VISUAL_ID == visualID || MetaclassEditPart.VISUAL_ID == visualID
- || CommentEditPart.VISUAL_ID == visualID || ConstraintEditPart.VISUAL_ID == visualID || ModelEditPartTN.VISUAL_ID == visualID || ProfileEditPartTN.VISUAL_ID == visualID || PackageEditPart.VISUAL_ID == visualID
- || EnumerationEditPart.VISUAL_ID == visualID || PrimitiveTypeEditPart.VISUAL_ID == visualID || DataTypeEditPart.VISUAL_ID == visualID || ShortCutDiagramEditPart.VISUAL_ID == visualID || PrimitiveTypeEditPartCN.VISUAL_ID == visualID
- || DataTypeOperationEditPart.VISUAL_ID == visualID || EnumerationLiteralEditPart.VISUAL_ID == visualID || DataTypePropertyEditPart.VISUAL_ID == visualID || ClassPropertyEditPart.VISUAL_ID == visualID
- || ClassOperationEditPart.VISUAL_ID == visualID || StereotypeEditPartCN.VISUAL_ID == visualID || ClassEditPartCN.VISUAL_ID == visualID || MetaclassEditPartCN.VISUAL_ID == visualID || CommentEditPartCN.VISUAL_ID == visualID
- || ModelEditPartCN.VISUAL_ID == visualID || ProfileEditPartCN.VISUAL_ID == visualID || PackageEditPartCN.VISUAL_ID == visualID || ConstraintEditPartCN.VISUAL_ID == visualID || EnumerationEditPartCN.VISUAL_ID == visualID
- || DataTypeEditPartCN.VISUAL_ID == visualID;
- }
-
- /**
- * @generated
- */
- protected boolean provides(CreateEdgeViewOperation op) {
- IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
- // RS: add code for extended types creation
- if (elementType instanceof IExtendedHintedElementType) {
- IElementType closestNonExtendedType = ElementTypeUtils.getClosestDiagramType(elementType);
- if (!UMLElementTypes.isKnownElementType(closestNonExtendedType) || (!(closestNonExtendedType instanceof IHintedType))) {
- return false; // foreign element type.
- }
- } else {
- if (!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) {
- return false; // foreign element type
- }
- }
- // if (!org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) {
- // return false; // foreign element type
- // }
- // END R.S.
- String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
- if (elementTypeHint == null || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) {
- return false; // our hint is visual id and must be specified, and it should be the same as in element type
- }
- int visualID = UMLVisualIDRegistry.getVisualID(elementTypeHint);
- EObject domainElement = getSemanticElement(op.getSemanticAdapter());
- if (domainElement != null && visualID != UMLVisualIDRegistry.getLinkWithClassVisualID(domainElement)) {
- return false; // visual id for link EClass should match visual id from element type
- }
- return true;
- }
-
- /**
- * @generated
- */
- @SuppressWarnings("unchecked")
- public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
- Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
- DiagramVersioningUtils.stampCurrentVersion(diagram);
- diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
- diagram.setType(ProfileDiagramEditPart.MODEL_ID);
- diagram.setElement(getSemanticElement(semanticAdapter));
- diagram.setMeasurementUnit(MeasurementUnit.PIXEL_LITERAL);
- return diagram;
- }
-
- /**
- * @generated
- */
- public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
- final EObject domainElement = getSemanticElement(semanticAdapter);
- final int visualID;
- if (semanticHint == null) {
- visualID = UMLVisualIDRegistry.getNodeVisualID(containerView, domainElement);
- } else {
- visualID = UMLVisualIDRegistry.getVisualID(semanticHint);
- }
- switch (visualID) {
- case DependencyNodeEditPart.VISUAL_ID:
- return createDependency_2014(domainElement, containerView, index, persisted, preferencesHint);
- case AssociationNodeEditPart.VISUAL_ID:
- return createAssociation_2015(domainElement, containerView, index, persisted, preferencesHint);
- case StereotypeEditPart.VISUAL_ID:
- return createStereotype_1026(domainElement, containerView, index, persisted, preferencesHint);
- case ClassEditPart.VISUAL_ID:
- return createClass_2008(domainElement, containerView, index, persisted, preferencesHint);
- case MetaclassEditPart.VISUAL_ID:
- return createClass_1031(domainElement, containerView, index, persisted, preferencesHint);
- case CommentEditPart.VISUAL_ID:
- return createComment_1002(domainElement, containerView, index, persisted, preferencesHint);
- case ConstraintEditPart.VISUAL_ID:
- return createConstraint_1014(domainElement, containerView, index, persisted, preferencesHint);
- case ModelEditPartTN.VISUAL_ID:
- return createModel_2005(domainElement, containerView, index, persisted, preferencesHint);
- case ProfileEditPartTN.VISUAL_ID:
- return createProfile_1030(domainElement, containerView, index, persisted, preferencesHint);
- case PackageEditPart.VISUAL_ID:
- return createPackage_2007(domainElement, containerView, index, persisted, preferencesHint);
- case EnumerationEditPart.VISUAL_ID:
- return createEnumeration_2006(domainElement, containerView, index, persisted, preferencesHint);
- case PrimitiveTypeEditPart.VISUAL_ID:
- return createPrimitiveType_2009(domainElement, containerView, index, persisted, preferencesHint);
- case DataTypeEditPart.VISUAL_ID:
- return createDataType_2010(domainElement, containerView, index, persisted, preferencesHint);
- case ShortCutDiagramEditPart.VISUAL_ID:
- return createDiagram_2016(domainElement, containerView, index, persisted, preferencesHint);
- case PrimitiveTypeEditPartCN.VISUAL_ID:
- return createPrimitiveType_3026(domainElement, containerView, index, persisted, preferencesHint);
- case DataTypeOperationEditPart.VISUAL_ID:
- return createOperation_3019(domainElement, containerView, index, persisted, preferencesHint);
- case EnumerationLiteralEditPart.VISUAL_ID:
- return createEnumerationLiteral_1037(domainElement, containerView, index, persisted, preferencesHint);
- case DataTypePropertyEditPart.VISUAL_ID:
- return createProperty_3018(domainElement, containerView, index, persisted, preferencesHint);
- case ClassPropertyEditPart.VISUAL_ID:
- return createProperty_3002(domainElement, containerView, index, persisted, preferencesHint);
- case ClassOperationEditPart.VISUAL_ID:
- return createOperation_3020(domainElement, containerView, index, persisted, preferencesHint);
- case StereotypeEditPartCN.VISUAL_ID:
- return createStereotype_1023(domainElement, containerView, index, persisted, preferencesHint);
- case ClassEditPartCN.VISUAL_ID:
- return createClass_3010(domainElement, containerView, index, persisted, preferencesHint);
- case MetaclassEditPartCN.VISUAL_ID:
- return createClass_3028(domainElement, containerView, index, persisted, preferencesHint);
- case CommentEditPartCN.VISUAL_ID:
- return createComment_1007(domainElement, containerView, index, persisted, preferencesHint);
- case ModelEditPartCN.VISUAL_ID:
- return createModel_1027(domainElement, containerView, index, persisted, preferencesHint);
- case ProfileEditPartCN.VISUAL_ID:
- return createProfile_1024(domainElement, containerView, index, persisted, preferencesHint);
- case PackageEditPartCN.VISUAL_ID:
- return createPackage_1012(domainElement, containerView, index, persisted, preferencesHint);
- case ConstraintEditPartCN.VISUAL_ID:
- return createConstraint_1028(domainElement, containerView, index, persisted, preferencesHint);
- case EnumerationEditPartCN.VISUAL_ID:
- return createEnumeration_3025(domainElement, containerView, index, persisted, preferencesHint);
- case DataTypeEditPartCN.VISUAL_ID:
- return createDataType_3027(domainElement, containerView, index, persisted, preferencesHint);
- }
- // can't happen, provided #provides(CreateNodeViewOperation) is correct
- return null;
- }
-
- /**
- * @generated
- */
- public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
- IElementType elementType = getSemanticElementType(semanticAdapter);
- String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
- switch (UMLVisualIDRegistry.getVisualID(elementTypeHint)) {
- case ExtensionEditPart.VISUAL_ID:
- return createExtension_1013(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
- case AssociationEditPart.VISUAL_ID:
- return createAssociation_4001(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
- case ProfileApplicationEditPart.VISUAL_ID:
- return createProfileApplication_1045(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
- case AssociationBranchEditPart.VISUAL_ID:
- return createAssociation_4019(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
- case GeneralizationEditPart.VISUAL_ID:
- return createGeneralization_4002(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
- case DependencyEditPart.VISUAL_ID:
- return createDependency_4008(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
- case DependencyBranchEditPart.VISUAL_ID:
- return createDependency_4018(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
- case ElementImportEditPart.VISUAL_ID:
- return createElementImport_1064(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
- case PackageImportEditPart.VISUAL_ID:
- return createPackageImport_1065(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
- case CommentAnnotatedElementEditPart.VISUAL_ID:
- return createCommentAnnotatedElement_1022(containerView, index, persisted, preferencesHint);
- case ConstraintConstrainedElementEditPart.VISUAL_ID:
- return createConstraintConstrainedElement_4014(containerView, index, persisted, preferencesHint);
- case ContextLinkEditPart.VISUAL_ID:
- return createConstraintContext_8500(containerView, index, persisted, preferencesHint);
- }
- // can never happen, provided #provides(CreateEdgeViewOperation) is correct
- return null;
- }
-
- /**
- * @generated
- */
- public Node createDependency_2014(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(DependencyNodeEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Dependency");
- Node label1 = createLabel(node, UMLVisualIDRegistry.getType(MultiDependencyLabelEditPart.VISUAL_ID));
- label1.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location1 = (Location) label1.getLayoutConstraint();
- location1.setX(0);
- location1.setY(5);
- return node;
- }
-
- /**
- * @generated
- */
- public Node createAssociation_2015(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(AssociationNodeEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "AssociationNode");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createStereotype_1026(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(StereotypeEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Stereotype");
- Node label1034 = createLabel(node, UMLVisualIDRegistry.getType(StereotypeNameEditPart.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(StereotypeAttributeCompartmentEditPart.VISUAL_ID), true, true, true, true);
- createCompartment(node, UMLVisualIDRegistry.getType(StereotypeOperationCompartmentEditPart.VISUAL_ID), true, true, true, true);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Stereotype");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createClass_2008(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(ClassEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Class");
- Node label5029 = createLabel(node, UMLVisualIDRegistry.getType(ClassNameEditPart.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(ClassOperationCompartmentEditPart.VISUAL_ID), true, true, true, true);
- createCompartment(node, UMLVisualIDRegistry.getType(ClassAttributeCompartmentEditPart.VISUAL_ID), true, true, true, true);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Class");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createClass_1031(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(MetaclassEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Metaclass");
- Node label1084 = createLabel(node, UMLVisualIDRegistry.getType(MetaclassNameEditPart.VISUAL_ID));
- return node;
- }
-
- /**
- * @generated
- */
- public Node createComment_1002(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(CommentEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Comment");
- Node label3 = createLabel(node, UMLVisualIDRegistry.getType(CommentBodyEditPart.VISUAL_ID));
- return node;
- }
-
- /**
- * @generated
- */
- public Node createConstraint_1014(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(ConstraintEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Constraint");
- Node label1015 = createLabel(node, UMLVisualIDRegistry.getType(ConstraintNameEditPart.VISUAL_ID));
- Node label5063 = createLabel(node, UMLVisualIDRegistry.getType(ConstraintBodyEditPart.VISUAL_ID));
- return node;
- }
-
- /**
- * @generated
- */
- public Node createModel_2005(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(ModelEditPartTN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Model");
- Node label5020 = createLabel(node, UMLVisualIDRegistry.getType(ModelNameEditPart.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(ModelPackageableElementCompartmentEditPartTN.VISUAL_ID), false, true, false, false);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Model");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createProfile_1030(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(ProfileEditPartTN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Profile");
- Node label1047 = createLabel(node, UMLVisualIDRegistry.getType(ProfileNameEditPartTN.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID), false, true, false, false);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Profile");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createPackage_2007(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(PackageEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Package");
- Node label5026 = createLabel(node, UMLVisualIDRegistry.getType(PackageNameEditPart.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(PackagePackageableElementCompartmentEditPart.VISUAL_ID), false, true, false, false);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Package");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createEnumeration_2006(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(EnumerationEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Enumeration");
- Node label5023 = createLabel(node, UMLVisualIDRegistry.getType(EnumerationNameEditPart.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID), true, true, true, true);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Enumeration");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createPrimitiveType_2009(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(PrimitiveTypeEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "PrimitiveType");
- Node label5032 = createLabel(node, UMLVisualIDRegistry.getType(PrimitiveTypeNameEditPart.VISUAL_ID));
- return node;
- }
-
- /**
- * @generated
- */
- public Node createDataType_2010(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(DataTypeEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DataType");
- Node label5035 = createLabel(node, UMLVisualIDRegistry.getType(DataTypeNameEditPart.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(DataTypeAttributeCompartmentEditPart.VISUAL_ID), true, true, true, true);
- createCompartment(node, UMLVisualIDRegistry.getType(DataTypeOperationCompartmentEditPart.VISUAL_ID), true, true, true, true);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "DataType");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createDiagram_2016(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(ShortCutDiagramEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- stampShortcut(containerView, node);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "ShortCutDiagram");
- Node label2 = createLabel(node, UMLVisualIDRegistry.getType(DiagramNameEditPart.VISUAL_ID));
- label2.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location2 = (Location) label2.getLayoutConstraint();
- location2.setX(0);
- location2.setY(5);
- return node;
- }
-
- /**
- * @generated
- */
- public Node createPrimitiveType_3026(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(PrimitiveTypeEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "PrimitiveType");
- Node label5058 = createLabel(node, UMLVisualIDRegistry.getType(PrimitiveTypeNameEditPartCN.VISUAL_ID));
- return node;
- }
-
- /**
- * @generated
- */
- public Node createOperation_3019(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Node node = NotationFactory.eINSTANCE.createNode();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- node.setType(UMLVisualIDRegistry.getType(DataTypeOperationEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Operation");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createEnumerationLiteral_1037(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Node node = NotationFactory.eINSTANCE.createNode();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- node.setType(UMLVisualIDRegistry.getType(EnumerationLiteralEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "EnumerationLiteral");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createProperty_3018(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Node node = NotationFactory.eINSTANCE.createNode();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- node.setType(UMLVisualIDRegistry.getType(DataTypePropertyEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Property");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createProperty_3002(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Node node = NotationFactory.eINSTANCE.createNode();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- node.setType(UMLVisualIDRegistry.getType(ClassPropertyEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Property");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createOperation_3020(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Node node = NotationFactory.eINSTANCE.createNode();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- node.setType(UMLVisualIDRegistry.getType(ClassOperationEditPart.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Operation");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createStereotype_1023(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(StereotypeEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Stereotype");
- Node label1046 = createLabel(node, UMLVisualIDRegistry.getType(StereotypeNameEditPartCN.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(StereotypeAttributeCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
- createCompartment(node, UMLVisualIDRegistry.getType(StereotypeOperationCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Stereotype");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createClass_3010(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(ClassEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Class");
- Node label5014 = createLabel(node, UMLVisualIDRegistry.getType(ClassNameEditPartCN.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(ClassAttributeCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
- createCompartment(node, UMLVisualIDRegistry.getType(ClassOperationCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Class");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createClass_3028(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(MetaclassEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Metaclass");
- Node label5062 = createLabel(node, UMLVisualIDRegistry.getType(MetaclassNameEditPartCN.VISUAL_ID));
- return node;
- }
-
- /**
- * @generated
- */
- public Node createComment_1007(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(CommentEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Comment");
- Node label1008 = createLabel(node, UMLVisualIDRegistry.getType(CommentBodyEditPartCN.VISUAL_ID));
- return node;
- }
-
- /**
- * @generated
- */
- public Node createModel_1027(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(ModelEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Model");
- Node label1056 = createLabel(node, UMLVisualIDRegistry.getType(ModelNameEditPartCN.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(ModelPackageableElementCompartmentEditPartCN.VISUAL_ID), false, true, false, false);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Model");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createProfile_1024(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(ProfileEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Profile");
- Node label1050 = createLabel(node, UMLVisualIDRegistry.getType(ProfileNameEditPartCN.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID), false, true, false, false);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Profile");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createPackage_1012(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(PackageEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Package");
- Node label1010 = createLabel(node, UMLVisualIDRegistry.getType(PackageNameEditPartCN.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(PackagePackageableElementCompartmentEditPartCN.VISUAL_ID), false, true, false, false);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Package");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createConstraint_1028(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(ConstraintEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Constraint");
- Node label1059 = createLabel(node, UMLVisualIDRegistry.getType(ConstraintNameEditPartCN.VISUAL_ID));
- Node label5064 = createLabel(node, UMLVisualIDRegistry.getType(ConstraintBodyEditPartCN.VISUAL_ID));
- return node;
- }
-
- /**
- * @generated
- */
- public Node createEnumeration_3025(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(EnumerationEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Enumeration");
- Node label5055 = createLabel(node, UMLVisualIDRegistry.getType(EnumerationNameEditPartCN.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Enumeration");
- return node;
- }
-
- /**
- * @generated
- */
- public Node createDataType_3027(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Shape node = NotationFactory.eINSTANCE.createShape();
- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(DataTypeEditPartCN.VISUAL_ID));
- ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DataType");
- Node label5061 = createLabel(node, UMLVisualIDRegistry.getType(DataTypeNameEditPartCN.VISUAL_ID));
- createCompartment(node, UMLVisualIDRegistry.getType(DataTypeAttributeCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
- createCompartment(node, UMLVisualIDRegistry.getType(DataTypeOperationCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "DataType");
- return node;
- }
-
- /**
- * @generated
- */
- public Edge createExtension_1013(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(ExtensionEditPart.VISUAL_ID));
- edge.setElement(domainElement);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Extension");
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createAssociation_4001(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(AssociationEditPart.VISUAL_ID));
- edge.setElement(domainElement);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Association");
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- Node label6001 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationAppliedStereotypeEditPart.VISUAL_ID));
- label6001.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6001 = (Location) label6001.getLayoutConstraint();
- location6001.setX(0);
- location6001.setY(60);
- Node label6002 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationNameEditPart.VISUAL_ID));
- label6002.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6002 = (Location) label6002.getLayoutConstraint();
- location6002.setX(0);
- location6002.setY(20);
- Node label6003 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationRoleTargetEditPart.VISUAL_ID));
- label6003.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6003 = (Location) label6003.getLayoutConstraint();
- location6003.setX(0);
- location6003.setY(20);
- Node label6005 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationRoleSourceEditPart.VISUAL_ID));
- label6005.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6005 = (Location) label6005.getLayoutConstraint();
- location6005.setX(0);
- location6005.setY(-20);
- Node label6033 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationMultiplicitySourceEditPart.VISUAL_ID));
- label6033.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6033 = (Location) label6033.getLayoutConstraint();
- location6033.setX(0);
- location6033.setY(20);
- Node label6034 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationMultiplicityTargetEditPart.VISUAL_ID));
- label6034.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6034 = (Location) label6034.getLayoutConstraint();
- location6034.setX(0);
- location6034.setY(-20);
- PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "Association");
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createProfileApplication_1045(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(ProfileApplicationEditPart.VISUAL_ID));
- edge.setElement(domainElement);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "ProfileApplication");
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createAssociation_4019(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(AssociationBranchEditPart.VISUAL_ID));
- edge.setElement(domainElement);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "AssociationBranch");
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- Node label6024 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationBranchRoleEditPart.VISUAL_ID));
- label6024.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6024 = (Location) label6024.getLayoutConstraint();
- location6024.setX(0);
- location6024.setY(-20);
- Node label6035 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationBranchMultiplicityEditPart.VISUAL_ID));
- label6035.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6035 = (Location) label6035.getLayoutConstraint();
- location6035.setX(0);
- location6035.setY(20);
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createGeneralization_4002(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(GeneralizationEditPart.VISUAL_ID));
- edge.setElement(domainElement);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Generalization");
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- Node label6007 = createLabel(edge, UMLVisualIDRegistry.getType(GeneralizationAppliedStereotypeEditPart.VISUAL_ID));
- label6007.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6007 = (Location) label6007.getLayoutConstraint();
- location6007.setX(0);
- location6007.setY(60);
- PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "Generalization");
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createDependency_4008(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(DependencyEditPart.VISUAL_ID));
- edge.setElement(domainElement);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Dependency");
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- Node label6026 = createLabel(edge, UMLVisualIDRegistry.getType(DependencyNameEditPart.VISUAL_ID));
- label6026.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6026 = (Location) label6026.getLayoutConstraint();
- location6026.setX(0);
- location6026.setY(40);
- Node label6027 = createLabel(edge, UMLVisualIDRegistry.getType(DependencyAppliedStereotypeEditPart.VISUAL_ID));
- label6027.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6027 = (Location) label6027.getLayoutConstraint();
- location6027.setX(0);
- location6027.setY(60);
- PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "Dependency");
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createDependency_4018(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(DependencyBranchEditPart.VISUAL_ID));
- edge.setElement(domainElement);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Dependency");
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createElementImport_1064(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(ElementImportEditPart.VISUAL_ID));
- edge.setElement(domainElement);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "ElementImport");
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- Node label6020 = createLabel(edge, UMLVisualIDRegistry.getType(ElementImportAliasEditPart.VISUAL_ID));
- label6020.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6020 = (Location) label6020.getLayoutConstraint();
- location6020.setX(0);
- location6020.setY(40);
- Node label6021 = createLabel(edge, UMLVisualIDRegistry.getType(AppliedStereotypeElementImportEditPart.VISUAL_ID));
- label6021.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6021 = (Location) label6021.getLayoutConstraint();
- location6021.setX(0);
- location6021.setY(60);
- PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "ElementImport");
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createPackageImport_1065(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(PackageImportEditPart.VISUAL_ID));
- edge.setElement(domainElement);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "PackageImport");
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- Node label6022 = createLabel(edge, UMLVisualIDRegistry.getType(PackageImportAppliedStereotypeEditPart.VISUAL_ID));
- label6022.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location6022 = (Location) label6022.getLayoutConstraint();
- location6022.setX(0);
- location6022.setY(60);
- PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "PackageImport");
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createCommentAnnotatedElement_1022(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(CommentAnnotatedElementEditPart.VISUAL_ID));
- edge.setElement(null);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createConstraintConstrainedElement_4014(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(ConstraintConstrainedElementEditPart.VISUAL_ID));
- edge.setElement(null);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- return edge;
- }
-
- /**
- * @generated
- */
- public Edge createConstraintContext_8500(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(ContextLinkEditPart.VISUAL_ID));
- edge.setElement(null);
- // initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
- // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- // if (routing != null) {
- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- // }
- return edge;
- }
-
- /**
- * @generated
- */
- protected void stampShortcut(View containerView, Node target) {
- if (!ProfileDiagramEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(containerView))) {
- EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
- shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$
- shortcutAnnotation.getDetails().put("modelID", ProfileDiagramEditPart.MODEL_ID); //$NON-NLS-1$
- target.getEAnnotations().add(shortcutAnnotation);
- }
- }
-
- /**
- * @generated
- */
- protected Node createLabel(View owner, String hint) {
- DecorationNode rv = NotationFactory.eINSTANCE.createDecorationNode();
- rv.setType(hint);
- ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true);
- return rv;
- }
-
- /**
- * @generated
- */
- protected Node createCompartment(View owner, String hint, boolean canCollapse, boolean hasTitle, boolean canSort, boolean canFilter) {
- // SemanticListCompartment rv = NotationFactory.eINSTANCE.createSemanticListCompartment();
- // rv.setShowTitle(showTitle);
- // rv.setCollapsed(isCollapsed);
- Node rv;
- if (canCollapse) {
- rv = NotationFactory.eINSTANCE.createBasicCompartment();
- } else {
- rv = NotationFactory.eINSTANCE.createDecorationNode();
- }
- rv.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- if (hasTitle) {
- TitleStyle ts = NotationFactory.eINSTANCE.createTitleStyle();
- rv.getStyles().add(ts);
- }
- if (canSort) {
- rv.getStyles().add(NotationFactory.eINSTANCE.createSortingStyle());
- }
- if (canFilter) {
- rv.getStyles().add(NotationFactory.eINSTANCE.createFilteringStyle());
- }
- rv.setType(hint);
- ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true);
- return rv;
- }
-
- /**
- * @generated
- */
- protected EObject getSemanticElement(IAdaptable semanticAdapter) {
- if (semanticAdapter == null) {
- return null;
- }
- EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
- if (eObject != null) {
- return EMFCoreUtil.resolve(TransactionUtil.getEditingDomain(eObject), eObject);
- }
- return null;
- }
-
- /**
- * @generated
- */
- protected IElementType getSemanticElementType(IAdaptable semanticAdapter) {
- if (semanticAdapter == null) {
- return null;
- }
- return (IElementType) semanticAdapter.getAdapter(IElementType.class);
- }
-
- /**
- * @generated
- */
- private void initFontStyleFromPrefs(View view, final IPreferenceStore store, String elementName) {
- String fontConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.FONT);
- String fontColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_FONT);
- FontStyle viewFontStyle = (FontStyle) view.getStyle(NotationPackage.Literals.FONT_STYLE);
- if (viewFontStyle != null) {
- FontData fontData = PreferenceConverter.getFontData(store, fontConstant);
- viewFontStyle.setFontName(fontData.getName());
- viewFontStyle.setFontHeight(fontData.getHeight());
- viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
- viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
- org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(store, fontColorConstant);
- viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
- }
- }
-
- /**
- * @generated
- */
- private void initForegroundFromPrefs(View view, final IPreferenceStore store, String elementName) {
- String lineColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_LINE);
- org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(store, lineColorConstant);
- ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB));
- }
-
- /**
- * @generated
- */
- private void initBackgroundFromPrefs(View view, final IPreferenceStore store, String elementName) {
- String fillColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_FILL);
- String gradientColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_GRADIENT);
- String gradientPolicyConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.GRADIENT_POLICY);
- org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(store, fillColorConstant);
- ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB));
- FillStyle fillStyle = (FillStyle) view.getStyle(NotationPackage.Literals.FILL_STYLE);
- fillStyle.setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue());
- ;
- if (store.getBoolean(gradientPolicyConstant)) {
- GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(store.getString(gradientColorConstant));
- fillStyle.setGradient(gradientPreferenceConverter.getGradientData());
- fillStyle.setTransparency(gradientPreferenceConverter.getTransparency());
- }
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.providers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
+import org.eclipse.gmf.runtime.notation.Connector;
+import org.eclipse.gmf.runtime.notation.DecorationNode;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.FillStyle;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.Location;
+import org.eclipse.gmf.runtime.notation.MeasurementUnit;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.Shape;
+import org.eclipse.gmf.runtime.notation.TitleStyle;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
+import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
+import org.eclipse.papyrus.uml.diagram.profile.edit.parts.*;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+
+/**
+ * @generated
+ */
+public class UMLViewProvider extends AbstractProvider implements IViewProvider {
+
+ /**
+ * @generated
+ */
+ public final boolean provides(IOperation operation) {
+ if (operation instanceof CreateViewForKindOperation) {
+ return provides((CreateViewForKindOperation) operation);
+ }
+ assert operation instanceof CreateViewOperation;
+ if (operation instanceof CreateDiagramViewOperation) {
+ return provides((CreateDiagramViewOperation) operation);
+ } else if (operation instanceof CreateEdgeViewOperation) {
+ return provides((CreateEdgeViewOperation) operation);
+ } else if (operation instanceof CreateNodeViewOperation) {
+ return provides((CreateNodeViewOperation) operation);
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateViewForKindOperation op) {
+ /*
+ if (op.getViewKind() == Node.class)
+ return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ if (op.getViewKind() == Edge.class)
+ return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ */
+ // check Diagram Type should be the class diagram
+ String modelID = UMLVisualIDRegistry.getModelID(op.getContainerView());
+ if (!getDiagramProvidedId().equals(modelID)) {
+ return false;
+ }
+ int visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint());
+ if (Node.class.isAssignableFrom(op.getViewKind())) {
+ return UMLVisualIDRegistry.canCreateNode(op.getContainerView(), visualID);
+ }
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getDiagramProvidedId() {
+ /*
+ * Indicates for which diagram this provider works for.
+ * <p>
+ * This method can be overloaded when diagram editor inherits from another one, but should never be <code>null</code>
+ * </p>
+ *
+ * @return the unique identifier of the diagram for which views are provided.
+ */
+ return ProfileDiagramEditPart.MODEL_ID;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateDiagramViewOperation op) {
+ return ProfileDiagramEditPart.MODEL_ID.equals(op.getSemanticHint()) && UMLVisualIDRegistry.getDiagramVisualID(getSemanticElement(op.getSemanticAdapter())) != -1;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateNodeViewOperation op) {
+ if (op.getContainerView() == null) {
+ return false;
+ }
+ IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
+ EObject domainElement = getSemanticElement(op.getSemanticAdapter());
+ int visualID;
+ if (op.getSemanticHint() == null) {
+ // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
+ // In this situation there should be NO elementType, visualID will be determined
+ // by VisualIDRegistry.getNodeVisualID() for domainElement.
+ if (elementType != null || domainElement == null) {
+ return false;
+ }
+ visualID = UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement);
+ } else {
+ visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint());
+ if (elementType != null) {
+ if (elementType instanceof IExtendedHintedElementType) {
+ if (domainElement != null) {
+ if (!UMLVisualIDRegistry.checkNodeVisualID(op.getContainerView(), domainElement, visualID)) {
+ return false;
+ }
+ }
+ } else {
+ if (!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) {
+ return false; // foreign element type
+ }
+ }
+ String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
+ if (!op.getSemanticHint().equals(elementTypeHint)) {
+ return false; // if semantic hint is specified it should be the same as in element type
+ }
+ if (domainElement != null && visualID != UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement)) {
+ return false; // visual id for node EClass should match visual id from element type
+ }
+ } else {
+ if (!ProfileDiagramEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(op.getContainerView()))) {
+ return false; // foreign diagram
+ }
+ switch (visualID) {
+ case DependencyNodeEditPart.VISUAL_ID:
+ case AssociationNodeEditPart.VISUAL_ID:
+ case StereotypeEditPart.VISUAL_ID:
+ case ClassEditPart.VISUAL_ID:
+ case CommentEditPart.VISUAL_ID:
+ case ConstraintEditPart.VISUAL_ID:
+ case ModelEditPartTN.VISUAL_ID:
+ case ProfileEditPartTN.VISUAL_ID:
+ case PackageEditPart.VISUAL_ID:
+ case EnumerationEditPart.VISUAL_ID:
+ case DataTypeEditPart.VISUAL_ID:
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ case PrimitiveTypeEditPartCN.VISUAL_ID:
+ case DataTypeOperationEditPart.VISUAL_ID:
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ case DataTypePropertyEditPart.VISUAL_ID:
+ case ClassPropertyEditPart.VISUAL_ID:
+ case ClassOperationEditPart.VISUAL_ID:
+ case StereotypeEditPartCN.VISUAL_ID:
+ case MetaclassEditPartCN.VISUAL_ID:
+ case CommentEditPartCN.VISUAL_ID:
+ case PackageEditPartCN.VISUAL_ID:
+ case ConstraintEditPartCN.VISUAL_ID:
+ case MetaclassEditPart.VISUAL_ID:
+ case PrimitiveTypeEditPart.VISUAL_ID:
+ case ClassEditPartCN.VISUAL_ID:
+ case ModelEditPartCN.VISUAL_ID:
+ case ProfileEditPartCN.VISUAL_ID:
+ case EnumerationEditPartCN.VISUAL_ID:
+ case DataTypeEditPartCN.VISUAL_ID:
+ if (domainElement == null || visualID != UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement)) {
+ return false; // visual id in semantic hint should match visual id for domain element
+ }
+ break;
+ default:
+ return false;
+ }
+ }
+ }
+ return DependencyNodeEditPart.VISUAL_ID == visualID || AssociationNodeEditPart.VISUAL_ID == visualID || StereotypeEditPart.VISUAL_ID == visualID || ClassEditPart.VISUAL_ID == visualID || MetaclassEditPart.VISUAL_ID == visualID || CommentEditPart.VISUAL_ID == visualID || ConstraintEditPart.VISUAL_ID == visualID || ModelEditPartTN.VISUAL_ID == visualID || ProfileEditPartTN.VISUAL_ID == visualID || PackageEditPart.VISUAL_ID == visualID || EnumerationEditPart.VISUAL_ID == visualID || PrimitiveTypeEditPart.VISUAL_ID == visualID || DataTypeEditPart.VISUAL_ID == visualID || ShortCutDiagramEditPart.VISUAL_ID == visualID || PrimitiveTypeEditPartCN.VISUAL_ID == visualID || DataTypeOperationEditPart.VISUAL_ID == visualID || EnumerationLiteralEditPart.VISUAL_ID == visualID || DataTypePropertyEditPart.VISUAL_ID == visualID || ClassPropertyEditPart.VISUAL_ID == visualID || ClassOperationEditPart.VISUAL_ID == visualID || StereotypeEditPartCN.VISUAL_ID == visualID || ClassEditPartCN.VISUAL_ID == visualID || MetaclassEditPartCN.VISUAL_ID == visualID || CommentEditPartCN.VISUAL_ID == visualID || ModelEditPartCN.VISUAL_ID == visualID || ProfileEditPartCN.VISUAL_ID == visualID || PackageEditPartCN.VISUAL_ID == visualID || ConstraintEditPartCN.VISUAL_ID == visualID || EnumerationEditPartCN.VISUAL_ID == visualID || DataTypeEditPartCN.VISUAL_ID == visualID;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateEdgeViewOperation op) {
+ IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
+ //RS: add code for extended types creation
+ if (elementType instanceof IExtendedHintedElementType) {
+ IElementType closestNonExtendedType = ElementTypeUtils.getClosestDiagramType(elementType);
+ if (!UMLElementTypes.isKnownElementType(closestNonExtendedType) || (!(closestNonExtendedType instanceof IHintedType))) {
+ return false; // foreign element type.
+ }
+ } else {
+ if (!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) {
+ return false; // foreign element type
+ }
+ }
+ //if (!org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) {
+ // return false; // foreign element type
+ //}
+ // END R.S.
+ String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
+ if (elementTypeHint == null || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) {
+ return false; // our hint is visual id and must be specified, and it should be the same as in element type
+ }
+ int visualID = UMLVisualIDRegistry.getVisualID(elementTypeHint);
+ EObject domainElement = getSemanticElement(op.getSemanticAdapter());
+ if (domainElement != null && visualID != UMLVisualIDRegistry.getLinkWithClassVisualID(domainElement)) {
+ return false; // visual id for link EClass should match visual id from element type
+ }
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
+ Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
+ diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
+ diagram.setType(ProfileDiagramEditPart.MODEL_ID);
+ diagram.setElement(getSemanticElement(semanticAdapter));
+ diagram.setMeasurementUnit(MeasurementUnit.PIXEL_LITERAL);
+ return diagram;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
+ final EObject domainElement = getSemanticElement(semanticAdapter);
+ final int visualID;
+ if (semanticHint == null) {
+ visualID = UMLVisualIDRegistry.getNodeVisualID(containerView, domainElement);
+ } else {
+ visualID = UMLVisualIDRegistry.getVisualID(semanticHint);
+ }
+ switch (visualID) {
+ case DependencyNodeEditPart.VISUAL_ID:
+ return createDependency_2014(domainElement, containerView, index, persisted, preferencesHint);
+ case AssociationNodeEditPart.VISUAL_ID:
+ return createAssociation_2015(domainElement, containerView, index, persisted, preferencesHint);
+ case StereotypeEditPart.VISUAL_ID:
+ return createStereotype_1026(domainElement, containerView, index, persisted, preferencesHint);
+ case ClassEditPart.VISUAL_ID:
+ return createClass_2008(domainElement, containerView, index, persisted, preferencesHint);
+ case MetaclassEditPart.VISUAL_ID:
+ return createClass_1031(domainElement, containerView, index, persisted, preferencesHint);
+ case CommentEditPart.VISUAL_ID:
+ return createComment_1002(domainElement, containerView, index, persisted, preferencesHint);
+ case ConstraintEditPart.VISUAL_ID:
+ return createConstraint_1014(domainElement, containerView, index, persisted, preferencesHint);
+ case ModelEditPartTN.VISUAL_ID:
+ return createModel_2005(domainElement, containerView, index, persisted, preferencesHint);
+ case ProfileEditPartTN.VISUAL_ID:
+ return createProfile_1030(domainElement, containerView, index, persisted, preferencesHint);
+ case PackageEditPart.VISUAL_ID:
+ return createPackage_2007(domainElement, containerView, index, persisted, preferencesHint);
+ case EnumerationEditPart.VISUAL_ID:
+ return createEnumeration_2006(domainElement, containerView, index, persisted, preferencesHint);
+ case PrimitiveTypeEditPart.VISUAL_ID:
+ return createPrimitiveType_2009(domainElement, containerView, index, persisted, preferencesHint);
+ case DataTypeEditPart.VISUAL_ID:
+ return createDataType_2010(domainElement, containerView, index, persisted, preferencesHint);
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ return createDiagram_2016(domainElement, containerView, index, persisted, preferencesHint);
+ case PrimitiveTypeEditPartCN.VISUAL_ID:
+ return createPrimitiveType_3026(domainElement, containerView, index, persisted, preferencesHint);
+ case DataTypeOperationEditPart.VISUAL_ID:
+ return createOperation_3019(domainElement, containerView, index, persisted, preferencesHint);
+ case EnumerationLiteralEditPart.VISUAL_ID:
+ return createEnumerationLiteral_1037(domainElement, containerView, index, persisted, preferencesHint);
+ case DataTypePropertyEditPart.VISUAL_ID:
+ return createProperty_3018(domainElement, containerView, index, persisted, preferencesHint);
+ case ClassPropertyEditPart.VISUAL_ID:
+ return createProperty_3002(domainElement, containerView, index, persisted, preferencesHint);
+ case ClassOperationEditPart.VISUAL_ID:
+ return createOperation_3020(domainElement, containerView, index, persisted, preferencesHint);
+ case StereotypeEditPartCN.VISUAL_ID:
+ return createStereotype_1023(domainElement, containerView, index, persisted, preferencesHint);
+ case ClassEditPartCN.VISUAL_ID:
+ return createClass_3010(domainElement, containerView, index, persisted, preferencesHint);
+ case MetaclassEditPartCN.VISUAL_ID:
+ return createClass_3028(domainElement, containerView, index, persisted, preferencesHint);
+ case CommentEditPartCN.VISUAL_ID:
+ return createComment_1007(domainElement, containerView, index, persisted, preferencesHint);
+ case ModelEditPartCN.VISUAL_ID:
+ return createModel_1027(domainElement, containerView, index, persisted, preferencesHint);
+ case ProfileEditPartCN.VISUAL_ID:
+ return createProfile_1024(domainElement, containerView, index, persisted, preferencesHint);
+ case PackageEditPartCN.VISUAL_ID:
+ return createPackage_1012(domainElement, containerView, index, persisted, preferencesHint);
+ case ConstraintEditPartCN.VISUAL_ID:
+ return createConstraint_1028(domainElement, containerView, index, persisted, preferencesHint);
+ case EnumerationEditPartCN.VISUAL_ID:
+ return createEnumeration_3025(domainElement, containerView, index, persisted, preferencesHint);
+ case DataTypeEditPartCN.VISUAL_ID:
+ return createDataType_3027(domainElement, containerView, index, persisted, preferencesHint);
+ }
+ // can't happen, provided #provides(CreateNodeViewOperation) is correct
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
+ IElementType elementType = getSemanticElementType(semanticAdapter);
+ String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
+ switch (UMLVisualIDRegistry.getVisualID(elementTypeHint)) {
+ case ExtensionEditPart.VISUAL_ID:
+ return createExtension_1013(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
+ case AssociationEditPart.VISUAL_ID:
+ return createAssociation_4001(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
+ case ProfileApplicationEditPart.VISUAL_ID:
+ return createProfileApplication_1045(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
+ case AssociationBranchEditPart.VISUAL_ID:
+ return createAssociation_4019(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
+ case GeneralizationEditPart.VISUAL_ID:
+ return createGeneralization_4002(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
+ case DependencyEditPart.VISUAL_ID:
+ return createDependency_4008(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
+ case DependencyBranchEditPart.VISUAL_ID:
+ return createDependency_4018(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
+ case ElementImportEditPart.VISUAL_ID:
+ return createElementImport_1064(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
+ case PackageImportEditPart.VISUAL_ID:
+ return createPackageImport_1065(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return createCommentAnnotatedElement_1022(containerView, index, persisted, preferencesHint);
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return createConstraintConstrainedElement_4014(containerView, index, persisted, preferencesHint);
+ case ContextLinkEditPart.VISUAL_ID:
+ return createConstraintContext_8500(containerView, index, persisted, preferencesHint);
+ }
+ // can never happen, provided #provides(CreateEdgeViewOperation) is correct
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createDependency_2014(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(DependencyNodeEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Dependency");
+ Node label1 = createLabel(node, UMLVisualIDRegistry.getType(MultiDependencyLabelEditPart.VISUAL_ID));
+ label1.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location1 = (Location) label1.getLayoutConstraint();
+ location1.setX(0);
+ location1.setY(5);
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createAssociation_2015(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(AssociationNodeEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "AssociationNode");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createStereotype_1026(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(StereotypeEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Stereotype");
+ Node label1034 = createLabel(node, UMLVisualIDRegistry.getType(StereotypeNameEditPart.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(StereotypeAttributeCompartmentEditPart.VISUAL_ID), true, true, true, true);
+ createCompartment(node, UMLVisualIDRegistry.getType(StereotypeOperationCompartmentEditPart.VISUAL_ID), true, true, true, true);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Stereotype");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createClass_2008(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ClassEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Class");
+ Node label5029 = createLabel(node, UMLVisualIDRegistry.getType(ClassNameEditPart.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(ClassOperationCompartmentEditPart.VISUAL_ID), true, true, true, true);
+ createCompartment(node, UMLVisualIDRegistry.getType(ClassAttributeCompartmentEditPart.VISUAL_ID), true, true, true, true);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Class");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createClass_1031(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(MetaclassEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Metaclass");
+ Node label1084 = createLabel(node, UMLVisualIDRegistry.getType(MetaclassNameEditPart.VISUAL_ID));
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createComment_1002(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(CommentEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Comment");
+ Node label3 = createLabel(node, UMLVisualIDRegistry.getType(CommentBodyEditPart.VISUAL_ID));
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createConstraint_1014(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ConstraintEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Constraint");
+ Node label1015 = createLabel(node, UMLVisualIDRegistry.getType(ConstraintNameEditPart.VISUAL_ID));
+ Node label5063 = createLabel(node, UMLVisualIDRegistry.getType(ConstraintBodyEditPart.VISUAL_ID));
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createModel_2005(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ModelEditPartTN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Model");
+ Node label5020 = createLabel(node, UMLVisualIDRegistry.getType(ModelNameEditPart.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(ModelPackageableElementCompartmentEditPartTN.VISUAL_ID), false, true, false, false);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Model");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createProfile_1030(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ProfileEditPartTN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Profile");
+ Node label1047 = createLabel(node, UMLVisualIDRegistry.getType(ProfileNameEditPartTN.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(ProfilePackageableElementCompartmentEditPartTN.VISUAL_ID), false, true, false, false);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Profile");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createPackage_2007(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(PackageEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Package");
+ Node label5026 = createLabel(node, UMLVisualIDRegistry.getType(PackageNameEditPart.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(PackagePackageableElementCompartmentEditPart.VISUAL_ID), false, true, false, false);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Package");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createEnumeration_2006(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(EnumerationEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Enumeration");
+ Node label5023 = createLabel(node, UMLVisualIDRegistry.getType(EnumerationNameEditPart.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID), true, true, true, true);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Enumeration");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createPrimitiveType_2009(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(PrimitiveTypeEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "PrimitiveType");
+ Node label5032 = createLabel(node, UMLVisualIDRegistry.getType(PrimitiveTypeNameEditPart.VISUAL_ID));
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createDataType_2010(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(DataTypeEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DataType");
+ Node label5035 = createLabel(node, UMLVisualIDRegistry.getType(DataTypeNameEditPart.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(DataTypeAttributeCompartmentEditPart.VISUAL_ID), true, true, true, true);
+ createCompartment(node, UMLVisualIDRegistry.getType(DataTypeOperationCompartmentEditPart.VISUAL_ID), true, true, true, true);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "DataType");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createDiagram_2016(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ShortCutDiagramEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "ShortCutDiagram");
+ Node label2 = createLabel(node, UMLVisualIDRegistry.getType(DiagramNameEditPart.VISUAL_ID));
+ label2.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location2 = (Location) label2.getLayoutConstraint();
+ location2.setX(0);
+ location2.setY(5);
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createPrimitiveType_3026(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(PrimitiveTypeEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "PrimitiveType");
+ Node label5058 = createLabel(node, UMLVisualIDRegistry.getType(PrimitiveTypeNameEditPartCN.VISUAL_ID));
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createOperation_3019(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Node node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ node.setType(UMLVisualIDRegistry.getType(DataTypeOperationEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Operation");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createEnumerationLiteral_1037(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Node node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ node.setType(UMLVisualIDRegistry.getType(EnumerationLiteralEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "EnumerationLiteral");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createProperty_3018(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Node node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ node.setType(UMLVisualIDRegistry.getType(DataTypePropertyEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Property");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createProperty_3002(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Node node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ node.setType(UMLVisualIDRegistry.getType(ClassPropertyEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Property");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createOperation_3020(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Node node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ node.setType(UMLVisualIDRegistry.getType(ClassOperationEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Operation");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createStereotype_1023(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(StereotypeEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Stereotype");
+ Node label1046 = createLabel(node, UMLVisualIDRegistry.getType(StereotypeNameEditPartCN.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(StereotypeAttributeCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
+ createCompartment(node, UMLVisualIDRegistry.getType(StereotypeOperationCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Stereotype");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createClass_3010(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ClassEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Class");
+ Node label5014 = createLabel(node, UMLVisualIDRegistry.getType(ClassNameEditPartCN.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(ClassAttributeCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
+ createCompartment(node, UMLVisualIDRegistry.getType(ClassOperationCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Class");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createClass_3028(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(MetaclassEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Metaclass");
+ Node label5062 = createLabel(node, UMLVisualIDRegistry.getType(MetaclassNameEditPartCN.VISUAL_ID));
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createComment_1007(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(CommentEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Comment");
+ Node label1008 = createLabel(node, UMLVisualIDRegistry.getType(CommentBodyEditPartCN.VISUAL_ID));
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createModel_1027(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ModelEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Model");
+ Node label1056 = createLabel(node, UMLVisualIDRegistry.getType(ModelNameEditPartCN.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(ModelPackageableElementCompartmentEditPartCN.VISUAL_ID), false, true, false, false);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Model");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createProfile_1024(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ProfileEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Profile");
+ Node label1050 = createLabel(node, UMLVisualIDRegistry.getType(ProfileNameEditPartCN.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(ProfilePackageableElementCompartmentEditPartCN.VISUAL_ID), false, true, false, false);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Profile");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createPackage_1012(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(PackageEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Package");
+ Node label1010 = createLabel(node, UMLVisualIDRegistry.getType(PackageNameEditPartCN.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(PackagePackageableElementCompartmentEditPartCN.VISUAL_ID), false, true, false, false);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Package");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createConstraint_1028(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ConstraintEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Constraint");
+ Node label1059 = createLabel(node, UMLVisualIDRegistry.getType(ConstraintNameEditPartCN.VISUAL_ID));
+ Node label5064 = createLabel(node, UMLVisualIDRegistry.getType(ConstraintBodyEditPartCN.VISUAL_ID));
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createEnumeration_3025(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(EnumerationEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Enumeration");
+ Node label5055 = createLabel(node, UMLVisualIDRegistry.getType(EnumerationNameEditPartCN.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Enumeration");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createDataType_3027(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(DataTypeEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DataType");
+ Node label5061 = createLabel(node, UMLVisualIDRegistry.getType(DataTypeNameEditPartCN.VISUAL_ID));
+ createCompartment(node, UMLVisualIDRegistry.getType(DataTypeAttributeCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
+ createCompartment(node, UMLVisualIDRegistry.getType(DataTypeOperationCompartmentEditPartCN.VISUAL_ID), true, true, true, true);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "DataType");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createExtension_1013(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(ExtensionEditPart.VISUAL_ID));
+ edge.setElement(domainElement);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Extension");
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createAssociation_4001(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(AssociationEditPart.VISUAL_ID));
+ edge.setElement(domainElement);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Association");
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ Node label6001 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationAppliedStereotypeEditPart.VISUAL_ID));
+ label6001.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6001 = (Location) label6001.getLayoutConstraint();
+ location6001.setX(0);
+ location6001.setY(60);
+ Node label6002 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationNameEditPart.VISUAL_ID));
+ label6002.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6002 = (Location) label6002.getLayoutConstraint();
+ location6002.setX(0);
+ location6002.setY(20);
+ Node label6003 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationRoleTargetEditPart.VISUAL_ID));
+ label6003.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6003 = (Location) label6003.getLayoutConstraint();
+ location6003.setX(0);
+ location6003.setY(20);
+ Node label6005 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationRoleSourceEditPart.VISUAL_ID));
+ label6005.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6005 = (Location) label6005.getLayoutConstraint();
+ location6005.setX(0);
+ location6005.setY(-20);
+ Node label6033 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationMultiplicitySourceEditPart.VISUAL_ID));
+ label6033.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6033 = (Location) label6033.getLayoutConstraint();
+ location6033.setX(0);
+ location6033.setY(20);
+ Node label6034 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationMultiplicityTargetEditPart.VISUAL_ID));
+ label6034.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6034 = (Location) label6034.getLayoutConstraint();
+ location6034.setX(0);
+ location6034.setY(-20);
+ PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "Association");
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createProfileApplication_1045(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(ProfileApplicationEditPart.VISUAL_ID));
+ edge.setElement(domainElement);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "ProfileApplication");
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createAssociation_4019(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(AssociationBranchEditPart.VISUAL_ID));
+ edge.setElement(domainElement);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "AssociationBranch");
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ Node label6024 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationBranchRoleEditPart.VISUAL_ID));
+ label6024.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6024 = (Location) label6024.getLayoutConstraint();
+ location6024.setX(0);
+ location6024.setY(-20);
+ Node label6035 = createLabel(edge, UMLVisualIDRegistry.getType(AssociationBranchMultiplicityEditPart.VISUAL_ID));
+ label6035.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6035 = (Location) label6035.getLayoutConstraint();
+ location6035.setX(0);
+ location6035.setY(20);
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createGeneralization_4002(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(GeneralizationEditPart.VISUAL_ID));
+ edge.setElement(domainElement);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Generalization");
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ Node label6007 = createLabel(edge, UMLVisualIDRegistry.getType(GeneralizationAppliedStereotypeEditPart.VISUAL_ID));
+ label6007.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6007 = (Location) label6007.getLayoutConstraint();
+ location6007.setX(0);
+ location6007.setY(60);
+ PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "Generalization");
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createDependency_4008(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(DependencyEditPart.VISUAL_ID));
+ edge.setElement(domainElement);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Dependency");
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ Node label6026 = createLabel(edge, UMLVisualIDRegistry.getType(DependencyNameEditPart.VISUAL_ID));
+ label6026.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6026 = (Location) label6026.getLayoutConstraint();
+ location6026.setX(0);
+ location6026.setY(40);
+ Node label6027 = createLabel(edge, UMLVisualIDRegistry.getType(DependencyAppliedStereotypeEditPart.VISUAL_ID));
+ label6027.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6027 = (Location) label6027.getLayoutConstraint();
+ location6027.setX(0);
+ location6027.setY(60);
+ PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "Dependency");
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createDependency_4018(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(DependencyBranchEditPart.VISUAL_ID));
+ edge.setElement(domainElement);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Dependency");
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createElementImport_1064(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(ElementImportEditPart.VISUAL_ID));
+ edge.setElement(domainElement);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "ElementImport");
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ Node label6020 = createLabel(edge, UMLVisualIDRegistry.getType(ElementImportAliasEditPart.VISUAL_ID));
+ label6020.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6020 = (Location) label6020.getLayoutConstraint();
+ location6020.setX(0);
+ location6020.setY(40);
+ Node label6021 = createLabel(edge, UMLVisualIDRegistry.getType(AppliedStereotypeElementImportEditPart.VISUAL_ID));
+ label6021.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6021 = (Location) label6021.getLayoutConstraint();
+ location6021.setX(0);
+ location6021.setY(60);
+ PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "ElementImport");
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createPackageImport_1065(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(PackageImportEditPart.VISUAL_ID));
+ edge.setElement(domainElement);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "PackageImport");
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ Node label6022 = createLabel(edge, UMLVisualIDRegistry.getType(PackageImportAppliedStereotypeEditPart.VISUAL_ID));
+ label6022.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location location6022 = (Location) label6022.getLayoutConstraint();
+ location6022.setX(0);
+ location6022.setY(60);
+ PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "PackageImport");
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createCommentAnnotatedElement_1022(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(CommentAnnotatedElementEditPart.VISUAL_ID));
+ edge.setElement(null);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createConstraintConstrainedElement_4014(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(ConstraintConstrainedElementEditPart.VISUAL_ID));
+ edge.setElement(null);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createConstraintContext_8500(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(ContextLinkEditPart.VISUAL_ID));
+ edge.setElement(null);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ protected void stampShortcut(View containerView, Node target) {
+ if (!ProfileDiagramEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(containerView))) {
+ EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$
+ shortcutAnnotation.getDetails().put("modelID", ProfileDiagramEditPart.MODEL_ID); //$NON-NLS-1$
+ target.getEAnnotations().add(shortcutAnnotation);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Node createLabel(View owner, String hint) {
+ DecorationNode rv = NotationFactory.eINSTANCE.createDecorationNode();
+ rv.setType(hint);
+ ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true);
+ return rv;
+ }
+
+ /**
+ * @generated
+ */
+ protected Node createCompartment(View owner, String hint, boolean canCollapse, boolean hasTitle, boolean canSort, boolean canFilter) {
+ //SemanticListCompartment rv = NotationFactory.eINSTANCE.createSemanticListCompartment();
+ //rv.setShowTitle(showTitle);
+ //rv.setCollapsed(isCollapsed);
+ Node rv;
+ if (canCollapse) {
+ rv = NotationFactory.eINSTANCE.createBasicCompartment();
+ } else {
+ rv = NotationFactory.eINSTANCE.createDecorationNode();
+ }
+ rv.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ if (hasTitle) {
+ TitleStyle ts = NotationFactory.eINSTANCE.createTitleStyle();
+ rv.getStyles().add(ts);
+ }
+ if (canSort) {
+ rv.getStyles().add(NotationFactory.eINSTANCE.createSortingStyle());
+ }
+ if (canFilter) {
+ rv.getStyles().add(NotationFactory.eINSTANCE.createFilteringStyle());
+ }
+ rv.setType(hint);
+ ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true);
+ return rv;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getSemanticElement(IAdaptable semanticAdapter) {
+ if (semanticAdapter == null) {
+ return null;
+ }
+ EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
+ if (eObject != null) {
+ return EMFCoreUtil.resolve(TransactionUtil.getEditingDomain(eObject), eObject);
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected IElementType getSemanticElementType(IAdaptable semanticAdapter) {
+ if (semanticAdapter == null) {
+ return null;
+ }
+ return (IElementType) semanticAdapter.getAdapter(IElementType.class);
+ }
+
+ /**
+ * @generated
+ */
+ private void initFontStyleFromPrefs(View view, final IPreferenceStore store, String elementName) {
+ String fontConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.FONT);
+ String fontColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_FONT);
+ FontStyle viewFontStyle = (FontStyle) view.getStyle(NotationPackage.Literals.FONT_STYLE);
+ if (viewFontStyle != null)
+ {
+ FontData fontData = PreferenceConverter.getFontData(store, fontConstant);
+ viewFontStyle.setFontName(fontData.getName());
+ viewFontStyle.setFontHeight(fontData.getHeight());
+ viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
+ viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
+ org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(store, fontColorConstant);
+ viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void initForegroundFromPrefs(View view, final IPreferenceStore store, String elementName) {
+ String lineColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_LINE);
+ org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(store, lineColorConstant);
+ ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB));
+ }
+
+ /**
+ * @generated
+ */
+ private void initBackgroundFromPrefs(View view, final IPreferenceStore store, String elementName) {
+ String fillColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_FILL);
+ String gradientColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_GRADIENT);
+ String gradientPolicyConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.GRADIENT_POLICY);
+ org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(store, fillColorConstant);
+ ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB));
+ FillStyle fillStyle = (FillStyle) view
+ .getStyle(NotationPackage.Literals.FILL_STYLE);
+ fillStyle
+ .setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue());
+ ;
+ if (store.getBoolean(gradientPolicyConstant)) {
+ GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(
+ store.getString(gradientColorConstant));
+ fillStyle.setGradient(gradientPreferenceConverter.getGradientData());
+ fillStyle
+ .setTransparency(gradientPreferenceConverter.getTransparency());
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/sheet/UMLPropertySection.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/sheet/UMLPropertySection.java
index ea1752e0d14..479e78806a8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/sheet/UMLPropertySection.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/sheet/UMLPropertySection.java
@@ -1,32 +1,32 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.sheet;
-
-import org.eclipse.gmf.tooling.runtime.sheet.DefaultPropertySection;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-
-/**
- * @generated
- */
-public class UMLPropertySection extends DefaultPropertySection implements IPropertySourceProvider {
-
- /**
- * Modify/unwrap selection.
- *
- * @generated
- */
- @Override
- protected Object transformSelection(Object selected) {
- selected = /* super. */transformSelectionToDomain(selected);
- return selected;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.sheet;
+
+import org.eclipse.gmf.tooling.runtime.sheet.DefaultPropertySection;
+import org.eclipse.ui.views.properties.IPropertySourceProvider;
+
+/**
+ * @generated
+ */
+public class UMLPropertySection extends DefaultPropertySection implements IPropertySourceProvider {
+
+ /**
+ * Modify/unwrap selection.
+ *
+ * @generated
+ */
+ @Override
+ protected Object transformSelection(Object selected) {
+ selected = /*super.*/transformSelectionToDomain(selected);
+ return selected;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/sheet/UMLSheetLabelProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/sheet/UMLSheetLabelProvider.java
index e0936faea25..860031aa869 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/sheet/UMLSheetLabelProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/sheet/UMLSheetLabelProvider.java
@@ -1,88 +1,90 @@
-/**
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- */
-package org.eclipse.papyrus.uml.diagram.profile.sheet;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.BaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.uml.diagram.profile.navigator.UMLNavigatorGroup;
-import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * @generated
- */
-public class UMLSheetLabelProvider extends BaseLabelProvider implements ILabelProvider {
-
- /**
- * @generated
- */
- public String getText(Object element) {
- element = unwrap(element);
- if (element instanceof UMLNavigatorGroup) {
- return ((UMLNavigatorGroup) element).getGroupName();
- }
- IElementType etype = getElementType(getView(element));
- return etype == null ? "" : etype.getDisplayName();
- }
-
- /**
- * @generated
- */
- public Image getImage(Object element) {
- IElementType etype = getElementType(getView(unwrap(element)));
- return etype == null ? null : UMLElementTypes.getImage(etype);
- }
-
- /**
- * @generated
- */
- private Object unwrap(Object element) {
- if (element instanceof IStructuredSelection) {
- return ((IStructuredSelection) element).getFirstElement();
- }
- return element;
- }
-
- /**
- * @generated
- */
- private View getView(Object element) {
- if (element instanceof View) {
- return (View) element;
- }
- if (element instanceof IAdaptable) {
- return (View) ((IAdaptable) element).getAdapter(View.class);
- }
- return null;
- }
-
- /**
- * @generated
- */
- private IElementType getElementType(View view) {
- // For intermediate views climb up the containment hierarchy to find the one associated with an element type.
- while (view != null) {
- int vid = UMLVisualIDRegistry.getVisualID(view);
- IElementType etype = UMLElementTypes.getElementType(vid);
- if (etype != null) {
- return etype;
- }
- view = view.eContainer() instanceof View ? (View) view.eContainer() : null;
- }
- return null;
- }
-}
+/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.profile.sheet;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.uml.diagram.profile.navigator.UMLNavigatorGroup;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class UMLSheetLabelProvider extends BaseLabelProvider implements ILabelProvider {
+
+ /**
+ * @generated
+ */
+ public String getText(Object element) {
+ element = unwrap(element);
+ if (element instanceof UMLNavigatorGroup) {
+ return ((UMLNavigatorGroup) element).getGroupName();
+ }
+ IElementType etype = getElementType(getView(element));
+ return etype == null ? "" : etype.getDisplayName();
+ }
+
+ /**
+ * @generated
+ */
+ public Image getImage(Object element) {
+ IElementType etype = getElementType(getView(unwrap(element)));
+ return etype == null ? null : UMLElementTypes.getImage(etype);
+ }
+
+ /**
+ * @generated
+ */
+ private Object unwrap(Object element) {
+ if (element instanceof IStructuredSelection) {
+ return ((IStructuredSelection) element).getFirstElement();
+ }
+ return element;
+ }
+
+ /**
+ * @generated
+ */
+ private View getView(Object element) {
+ if (element instanceof View) {
+ return (View) element;
+ }
+ if (element instanceof IAdaptable) {
+ return (View) ((IAdaptable) element).getAdapter(View.class);
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private IElementType getElementType(View view) {
+ // For intermediate views climb up the containment hierarchy to find the one associated with an element type.
+ while (view != null) {
+ int vid = UMLVisualIDRegistry.getVisualID(view);
+ IElementType etype =
+ UMLElementTypes.getElementType(vid);
+ if (etype != null) {
+ return etype;
+ }
+ view = view.eContainer() instanceof View ?
+ (View) view.eContainer() : null;
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ICustomAppearance.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ICustomAppearance.java
index 646da6f7480..e00aa2d3074 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ICustomAppearance.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ICustomAppearance.java
@@ -1,156 +1,162 @@
-/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Remi SCHNEKENBURGER (CEA LIST) Remi.schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.tools.utils;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-/**
- * Interface that manages display constants for custom labels (ex: operations label in a class
- * diagram).
- */
-public interface ICustomAppearance {
-
- /**
- * key for the appearance property of graph nodes.
- */
- // @unused
- public final static String CUSTOM_APPEARENCE_KEY = "custom_disp";
-
- // /////////////////////////////////////////////////////////////////////////
- // Style constants
- // /////////////////////////////////////////////////////////////////////////
- /**
- * Style constant for visibility display in labels.
- */
- public final static String DISP_VISIBILITY = "visibility";
-
- /**
- * Style constant for isDerive display in labels.
- */
- public final static String DISP_DERIVE = "derived";
-
- /**
- * Style constant for name display in labels.
- */
- public final static String DISP_NAME = "name";
-
- /**
- * Style constant for type display in labels.
- */
- public final static String DISP_TYPE = "type";
-
- /**
- * Style constant for multiplicity display in labels.
- */
- public final static String DISP_MULTIPLICITY = "multiplicity";
-
- /**
- * Style constant for default value display in labels.
- */
- public final static String DISP_DEFAULT_VALUE = "defaultValue";
-
- /**
- * Style constant for modifiers display in labels.
- */
- public final static String DISP_MODIFIERS = "modifiers";
-
- /** Style constant for carriage return in labels */
- public final static String DISP_MULTI_LINE = "multiline";
-
- /** Prefix used to distinguish parameter-specific values (e.g. name vs parametersName, for an Operation) */
- public final static String PARAMETERS_PREFIX = "parameters";
-
- /** Style constant for operation#parameter direction display in labels */
- public final String DISP_PARAMETER_DIRECTION = PARAMETERS_PREFIX + "Direction";
-
- /** Style constant for direction display in labels */
- public final String DISP_DIRECTION = "direction";
-
- /** Style constant for operation#parameter name display in labels */
- public final String DISP_PARAMETER_NAME = PARAMETERS_PREFIX + "Name";
-
- /** Style constant for operation#parameter type display in labels */
- public final String DISP_PARAMETER_TYPE = PARAMETERS_PREFIX + "Type";
-
- /** Style constant for operation#parameter multiplicity display in labels */
- public final String DISP_PARAMETER_MULTIPLICITY = PARAMETERS_PREFIX + "Multiplicity";
-
- /** Style constant for operation#parameter default value display in labels */
- public final String DISP_PARAMETER_DEFAULT = PARAMETERS_PREFIX + "Default";
-
- /** Style constant for operation#parameter modifiers display in labels */
- public final String DISP_PARAMETER_MODIFIERS = PARAMETERS_PREFIX + "Modifiers";
-
- /** Style constant for return type display in labels */
- public final String DISP_RT_TYPE = "returnType";
-
- /** Style constant for return multiplicity display in labels */
- public final String DISP_RT_MULTIPLICITY = "returnMultiplicity";
-
- /** Style constant for conjugated labels */
- public final String DISP_CONJUGATED = "conjugated";
-
- // /////////////////////////////////////////////////////////////////////////
- // UML DEFAULT DISPLAY
- // /////////////////////////////////////////////////////////////////////////
- /**
- * default uml property display in classes edit part.
- */
- public final static Collection<String> DEFAULT_UML_PROPERTY = Arrays.asList(DISP_VISIBILITY, DISP_DERIVE, DISP_NAME, DISP_TYPE, DISP_MULTIPLICITY);
-
- /**
- * default uml property display in classes edit part.
- */
- public final static Collection<String> DEFAULT_UML_ROLE = Arrays.asList(DISP_VISIBILITY, DISP_DERIVE, DISP_NAME, DISP_TYPE);
-
- /**
- * default uml operation display.
- */
- public final static Collection<String> DEFAULT_UML_OPERATION = Arrays.asList(DISP_VISIBILITY, DISP_NAME, DISP_PARAMETER_DIRECTION, DISP_PARAMETER_TYPE, DISP_RT_TYPE, DISP_PARAMETER_NAME);
-
- /**
- * default uml Property in composite diagrams.
- */
- // @unused
- public final static Collection<String> DEFAULT_UML_COMPO_PROPERTY = Arrays.asList(DISP_NAME, DISP_TYPE);
-
- /**
- * default uml Property in class diagrams as association ends.
- */
- // @unused
- public final static Collection<String> DEFAULT_UML_RELATIONEND_PROPERTY = Arrays.asList(DISP_VISIBILITY, DISP_DERIVE, DISP_NAME, DISP_MODIFIERS, DISP_MULTI_LINE);
-
- /**
- * default uml Port ins composite diagrams.
- */
- public final static Collection<String> DEFAULT_UML_PORT = Arrays.asList(DISP_VISIBILITY, DISP_DERIVE, DISP_NAME, DISP_TYPE, DISP_MULTIPLICITY, DISP_CONJUGATED);
-
- /**
- * default uml OpaqueAction in activity diagrams.
- */
- // @unused
- public final static Collection<String> DEFAULT_UML_OPAQUE_ACTION = Arrays.asList(DISP_NAME);
-
- /**
- * default uml Parameter in composite diagrams.
- */
- public final static Collection<String> DEFAULT_UML_PARAMETER = Arrays.asList(DISP_DIRECTION, DISP_NAME, DISP_TYPE);
-
- /**
- * default uml instancespecification .
- */
- public final static Collection<String> DEFAULT_UML_INSTANCESPECIFICATION = Arrays.asList(DISP_NAME, DISP_TYPE);
-
-}
+/*****************************************************************************
+ * Copyright (c) 2008 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Remi SCHNEKENBURGER (CEA LIST) Remi.schnekenburger@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.utils;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * Interface that manages display constants for custom labels (ex: operations label in a class
+ * diagram).
+ */
+public interface ICustomAppearance {
+
+ /**
+ * key for the appearance property of graph nodes.
+ */
+ // @unused
+ public final static String CUSTOM_APPEARENCE_KEY = "custom_disp";
+
+ // /////////////////////////////////////////////////////////////////////////
+ // Style constants
+ // /////////////////////////////////////////////////////////////////////////
+ /**
+ * Style constant for visibility display in labels.
+ */
+ public final static String DISP_VISIBILITY = "visibility";
+
+ /**
+ * Style constant for isDerive display in labels.
+ */
+ public final static String DISP_DERIVE = "derived";
+
+ /**
+ * Style constant for name display in labels.
+ */
+ public final static String DISP_NAME = "name";
+
+ /**
+ * Style constant for type display in labels.
+ */
+ public final static String DISP_TYPE = "type";
+
+ /**
+ * Style constant for multiplicity display in labels.
+ */
+ public final static String DISP_MULTIPLICITY = "multiplicity";
+
+ /**
+ * Style constant for default value display in labels.
+ */
+ public final static String DISP_DEFAULT_VALUE = "defaultValue";
+
+ /**
+ * Style constant for modifiers display in labels.
+ */
+ public final static String DISP_MODIFIERS = "modifiers";
+
+ /** Style constant for carriage return in labels */
+ public final static String DISP_MULTI_LINE = "multiline";
+
+ /** Prefix used to distinguish parameter-specific values (e.g. name vs parametersName, for an Operation) */
+ public final static String PARAMETERS_PREFIX = "parameters";
+
+ /** Style constant for operation#parameter direction display in labels */
+ public final String DISP_PARAMETER_DIRECTION = PARAMETERS_PREFIX + "Direction";
+
+ /** Style constant for direction display in labels */
+ public final String DISP_DIRECTION = "direction";
+
+ /** Style constant for operation#parameter name display in labels */
+ public final String DISP_PARAMETER_NAME = PARAMETERS_PREFIX + "Name";
+
+ /** Style constant for operation#parameter type display in labels */
+ public final String DISP_PARAMETER_TYPE = PARAMETERS_PREFIX + "Type";
+
+ /** Style constant for operation#parameter multiplicity display in labels */
+ public final String DISP_PARAMETER_MULTIPLICITY = PARAMETERS_PREFIX + "Multiplicity";
+
+ /** Style constant for operation#parameter default value display in labels */
+ public final String DISP_PARAMETER_DEFAULT = PARAMETERS_PREFIX + "Default";
+
+ /** Style constant for operation#parameter modifiers display in labels */
+ public final String DISP_PARAMETER_MODIFIERS = PARAMETERS_PREFIX + "Modifiers";
+
+ /** Style constant for return type display in labels */
+ public final String DISP_RT_TYPE = "returnType";
+
+ /** Style constant for return multiplicity display in labels */
+ public final String DISP_RT_MULTIPLICITY = "returnMultiplicity";
+
+ /** Style constant for conjugated labels */
+ public final String DISP_CONJUGATED = "conjugated";
+
+ // /////////////////////////////////////////////////////////////////////////
+ // UML DEFAULT DISPLAY
+ // /////////////////////////////////////////////////////////////////////////
+ /**
+ * default uml property display in classes edit part.
+ */
+ public final static Collection<String> DEFAULT_UML_PROPERTY = Arrays.asList(DISP_VISIBILITY, DISP_DERIVE, DISP_NAME, DISP_TYPE, DISP_MULTIPLICITY);
+
+ /**
+ * default uml property display in for floating label edit part.
+ */
+ public final static Collection<String> DEFAULT_UML_FLOATING_LABEL = Arrays.asList(DISP_NAME);
+
+
+ /**
+ * default uml property display in classes edit part.
+ */
+ public final static Collection<String> DEFAULT_UML_ROLE = Arrays.asList(DISP_VISIBILITY, DISP_DERIVE, DISP_NAME, DISP_TYPE);
+
+ /**
+ * default uml operation display.
+ */
+ public final static Collection<String> DEFAULT_UML_OPERATION = Arrays.asList(DISP_VISIBILITY, DISP_NAME, DISP_PARAMETER_DIRECTION, DISP_PARAMETER_TYPE, DISP_RT_TYPE, DISP_PARAMETER_NAME);
+
+ /**
+ * default uml Property in composite diagrams.
+ */
+ // @unused
+ public final static Collection<String> DEFAULT_UML_COMPO_PROPERTY = Arrays.asList(DISP_NAME, DISP_TYPE);
+
+ /**
+ * default uml Property in class diagrams as association ends.
+ */
+ // @unused
+ public final static Collection<String> DEFAULT_UML_RELATIONEND_PROPERTY = Arrays.asList(DISP_VISIBILITY, DISP_DERIVE, DISP_NAME, DISP_MODIFIERS, DISP_MULTI_LINE);
+
+ /**
+ * default uml Port ins composite diagrams.
+ */
+ public final static Collection<String> DEFAULT_UML_PORT = Arrays.asList(DISP_VISIBILITY, DISP_DERIVE, DISP_NAME, DISP_TYPE, DISP_MULTIPLICITY, DISP_CONJUGATED);
+
+ /**
+ * default uml OpaqueAction in activity diagrams.
+ */
+ // @unused
+ public final static Collection<String> DEFAULT_UML_OPAQUE_ACTION = Arrays.asList(DISP_NAME);
+
+ /**
+ * default uml Parameter in composite diagrams.
+ */
+ public final static Collection<String> DEFAULT_UML_PARAMETER = Arrays.asList(DISP_DIRECTION, DISP_NAME, DISP_TYPE);
+
+ /**
+ * default uml instancespecification .
+ */
+ public final static Collection<String> DEFAULT_UML_INSTANCESPECIFICATION = Arrays.asList(DISP_NAME, DISP_TYPE);
+
+}

Back to the top