From 836653106b3f1b7cee7b1e204fe6060156c094e2 Mon Sep 17 00:00:00 2001 From: Kevin Kassin <KK@Medion-PC> Date: Tue, 25 Jul 2017 17:27:02 +0200 Subject: [PATCH] #Commit 25.7 17:25 implemented first non fully working version of role implication --- ...on.png => icon_relationship_exclusion.png} | Bin .../FRaMEDDeleteConnectionFeature.java | 1 - .../iorm/ui/literals/IdentifierLiterals.java | 4 +- .../framed/iorm/ui/literals/NameLiterals.java | 8 +- .../framed/iorm/ui/literals/URLLiterals.java | 6 +- .../connections/FRaMEDConnectionPattern.java | 2 +- .../connections/InheritancePattern.java | 14 +-- .../connections/RelationshipPattern.java | 19 ++-- ...actInterRelationshipConstraintPattern.java | 102 +++++++++++++++++- ...ationshipImplicationConstraintPattern.java | 53 +++++++++ ...actIntraRelationshipConstraintPattern.java | 6 +- .../AbstractRoleConstraintPattern.java | 10 +- .../RoleEquivalencePattern.java | 6 +- .../RoleImplicationPattern.java | 4 +- .../RoleProhibitionPattern.java | 6 +- .../iorm/ui/providers/FeatureProvider.java | 3 + .../iorm/ui/providers/ImageProvider.java | 10 +- .../ui/providers/ToolBehaviorProvider.java | 7 +- .../iorm/ui/util/ConnectionPatternUtil.java | 14 ++- 19 files changed, 223 insertions(+), 52 deletions(-) rename org.framed.iorm.ui/icons/features/{icon_relationship_prohibition.png => icon_relationship_exclusion.png} (100%) diff --git a/org.framed.iorm.ui/icons/features/icon_relationship_prohibition.png b/org.framed.iorm.ui/icons/features/icon_relationship_exclusion.png similarity index 100% rename from org.framed.iorm.ui/icons/features/icon_relationship_prohibition.png rename to org.framed.iorm.ui/icons/features/icon_relationship_exclusion.png diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/FRaMEDDeleteConnectionFeature.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/FRaMEDDeleteConnectionFeature.java index 0600c2be..18eef98f 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/FRaMEDDeleteConnectionFeature.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/FRaMEDDeleteConnectionFeature.java @@ -3,7 +3,6 @@ package org.framed.iorm.ui.graphitifeatures; import java.util.ArrayList; import java.util.List; -import org.eclipse.graphiti.features.IDeleteFeature; import org.eclipse.graphiti.features.IFeatureProvider; import org.eclipse.graphiti.features.context.IDeleteContext; import org.eclipse.graphiti.features.context.impl.DeleteContext; diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/IdentifierLiterals.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/IdentifierLiterals.java index b6ad421f..f9442a30 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/IdentifierLiterals.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/IdentifierLiterals.java @@ -65,7 +65,9 @@ public class IdentifierLiterals { IMG_ID_FEATURE_ROLEEQUIVALENCE = IMG_ID_PREFIX + "img_roleequivalence", IMG_ID_FEATURE_ROLEPROHIBITION = IMG_ID_PREFIX + "img_roleprohibition", IMG_ID_FEATURE_RELATIONSHIP = IMG_ID_PREFIX + "img_relationship", - IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IMG_ID_PREFIX + "img_intrarelationship_constraint"; + IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IMG_ID_PREFIX + "img_intrarelationship_constraint", + IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION = IMG_ID_PREFIX + "img_relationship_implication", + IMG_ID_FEATURE_RELATIONSHIP_EXCLUSION = IMG_ID_PREFIX + "img_relationship_exclusion"; /** * feature model identifier diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/NameLiterals.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/NameLiterals.java index cd6403da..9ee84ebe 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/NameLiterals.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/NameLiterals.java @@ -94,7 +94,9 @@ public class NameLiterals { * (7) the name of the cyclic constraint create feature or<br> * (8) the name of the irreflexive constraint create feature or<br> * (9) the name of the reflexive constraint create feature or<br> - * (10) the name of the total constraint create feature + * (10) the name of the total constraint create feature or<br> + * (11) the name of the relationship implication create feature or<br> + * (12) the name of the relationship exclusion create feature */ public static final String INHERITANCE_FEATURE_NAME = "Inheritance", ROLEIMPLICATION_FEATURE_NAME = "Role Implication", @@ -105,7 +107,9 @@ public class NameLiterals { CYCLIC_FEATURE_NAME = "Cyclic", IRREFLEXIVE_FEATURE_NAME = "Irreflexve", REFLEXIVE_FEATURE_NAME = "Reflexive", - TOTAL_FEATURE_NAME = "Total"; + TOTAL_FEATURE_NAME = "Total", + RELATIONSHIP_IMPLICATION_FEATURE_NAME = "Relationship Implication", + RELATIONSHIP_EXCLUSION_FEATURE_NAME = "Relationship Exclusion"; /** * name literals used in the patterns to be identified by the ToolBehaviorProvider diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/URLLiterals.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/URLLiterals.java index 45dbf50f..c2970507 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/URLLiterals.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/URLLiterals.java @@ -68,5 +68,7 @@ public class URLLiterals { IMG_FILEPATH_FEATURE_ROLEEQUIVALENCE = IMG_FILE_PATH_PREFIX + "roleequivalence.png", IMG_FILEPATH_FEATURE_ROLEPROHIBITION = IMG_FILE_PATH_PREFIX + "roleprohibition.png", IMG_FILEPATH_FEATURE_RELATIONSHIP = IMG_FILE_PATH_PREFIX + "relationship.png", - IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IMG_FILE_PATH_PREFIX + "intrarelationship_constraint.png"; -} + IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IMG_FILE_PATH_PREFIX + "intrarelationship_constraint.png", + IMG_FILEPATH_FEATURE_RELATIONSHIP_IMPLICATION = IMG_FILE_PATH_PREFIX + "relationship_implication.png", + IMG_FILEPATH_FEATURE_RELATIONSHIP_EXCLUSION = IMG_FILE_PATH_PREFIX + "relationship_exclusion.png"; +} \ No newline at end of file diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/FRaMEDConnectionPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/FRaMEDConnectionPattern.java index 02d4a756..35a82f88 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/FRaMEDConnectionPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/FRaMEDConnectionPattern.java @@ -23,7 +23,7 @@ public class FRaMEDConnectionPattern extends AbstractConnectionPattern { /** * the pictogram elements service used to creates pictogram elements in the subclasses */ - protected final IPeCreateService pictogramElementCreateSerive = Graphiti.getPeCreateService(); + protected final IPeCreateService pictogramElementCreateService = Graphiti.getPeCreateService(); /** * the graphics algorithm service used to create graphics algorithms in the subclasses diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/InheritancePattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/InheritancePattern.java index fa8b3fed..69448524 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/InheritancePattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/InheritancePattern.java @@ -115,7 +115,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { Anchor sourceAnchor = addConnectionContext.getSourceAnchor(); Anchor targetAnchor = addConnectionContext.getTargetAnchor(); //Step 1 - Connection connection = pictogramElementCreateSerive.createFreeFormConnection(getDiagram()); + Connection connection = pictogramElementCreateService.createFreeFormConnection(getDiagram()); connection.setStart(sourceAnchor); connection.setEnd(targetAnchor); Polyline polyline = graphicAlgorithmService.createPolyline(connection); @@ -123,7 +123,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { polyline.setLineWidth(2); //Step2 ConnectionDecorator connectionDecorator; - connectionDecorator = pictogramElementCreateSerive.createConnectionDecorator(connection, false, 1.0, true); + connectionDecorator = pictogramElementCreateService.createConnectionDecorator(connection, false, 1.0, true); int points[] = new int[] { -1*INHERITANCE_ARROWHEAD_LENGTH, INHERITANCE_ARROWHEAD_HEIGHT, //Point 1 0, 0, //P2 -1*INHERITANCE_ARROWHEAD_LENGTH, -1*INHERITANCE_ARROWHEAD_HEIGHT }; //P3 @@ -153,8 +153,8 @@ public class InheritancePattern extends FRaMEDConnectionPattern { public boolean canCreate(ICreateConnectionContext createContext) { Anchor sourceAnchor = createContext.getSourceAnchor(); Anchor targetAnchor = createContext.getTargetAnchor(); - org.framed.iorm.model.Shape sourceShape = ConnectionPatternUtil.getShapeForAnchor(sourceAnchor); - org.framed.iorm.model.Shape targetShape = ConnectionPatternUtil.getShapeForAnchor(targetAnchor); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement targetShape = ConnectionPatternUtil.getModelElementForAnchor(targetAnchor); if(sourceShape != null && targetShape != null) { if(sourceShape.getContainer() == targetShape.getContainer() && !(sourceShape.equals(targetShape))) { @@ -179,7 +179,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { @Override public boolean canStartConnection(ICreateConnectionContext createContext) { Anchor sourceAnchor = createContext.getSourceAnchor(); - org.framed.iorm.model.Shape sourceShape = ConnectionPatternUtil.getShapeForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); if(sourceShape != null){ if(sourceShape.getType() == Type.NATURAL_TYPE || sourceShape.getType() == Type.DATA_TYPE || @@ -203,8 +203,8 @@ public class InheritancePattern extends FRaMEDConnectionPattern { //Step 1 Anchor sourceAnchor = createContext.getSourceAnchor(); Anchor targetAnchor = createContext.getTargetAnchor(); - org.framed.iorm.model.Shape sourceShape = ConnectionPatternUtil.getShapeForAnchor(sourceAnchor); - org.framed.iorm.model.Shape targetShape = ConnectionPatternUtil.getShapeForAnchor(targetAnchor); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement targetShape = ConnectionPatternUtil.getModelElementForAnchor(targetAnchor); //Step 2 Relation newInheritance = OrmFactory.eINSTANCE.createRelation(); newInheritance.setType(Type.INHERITANCE); diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/RelationshipPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/RelationshipPattern.java index cfd82213..309ef964 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/RelationshipPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/RelationshipPattern.java @@ -134,7 +134,7 @@ public class RelationshipPattern extends FRaMEDConnectionPattern { Anchor sourceAnchor = addConnectionContext.getSourceAnchor(); Anchor targetAnchor = addConnectionContext.getTargetAnchor(); //Step 1 - Connection connection = pictogramElementCreateSerive.createFreeFormConnection(getDiagram()); + Connection connection = pictogramElementCreateService.createFreeFormConnection(getDiagram()); connection.setStart(sourceAnchor); connection.setEnd(targetAnchor); Polyline polyline = graphicAlgorithmService.createPolyline(connection); @@ -142,21 +142,21 @@ public class RelationshipPattern extends FRaMEDConnectionPattern { polyline.setLineWidth(2); //Step 2 ConnectionDecorator connectionDecoratorForName = - pictogramElementCreateSerive.createConnectionDecorator(connection, true, 0.5, true); + pictogramElementCreateService.createConnectionDecorator(connection, true, 0.5, true); Text nameText = graphicAlgorithmService.createText(connectionDecoratorForName, addedRelationship.getName()); graphicAlgorithmService.setLocation(nameText, 0, -1*DISTANCE_FROM_CONNECTION_LINE); nameText.setForeground(manageColor(COLOR_TEXT)); PropertyUtil.setShape_IdValue(connectionDecoratorForName, SHAPE_ID_RELATIONSHIP_NAME_DECORATOR); //Step 3 ConnectionDecorator connectionDecoratorForSourceLabel = - pictogramElementCreateSerive.createConnectionDecorator(connection, true, 0.1, true); + pictogramElementCreateService.createConnectionDecorator(connection, true, 0.1, true); Text sourceLabel = graphicAlgorithmService.createText(connectionDecoratorForSourceLabel, addedRelationship.getSourceLabel().getName()); graphicAlgorithmService.setLocation(sourceLabel, 0, -1*DISTANCE_FROM_CONNECTION_LINE); sourceLabel.setForeground(manageColor(COLOR_TEXT)); PropertyUtil.setShape_IdValue(connectionDecoratorForSourceLabel, SHAPE_ID_RELATIONSHIP_SOURCE_CARDINALITY_DECORATOR); //Step 3 ConnectionDecorator connectionDecoratorForTargetLabel = - pictogramElementCreateSerive.createConnectionDecorator(connection, true, 0.9, true); + pictogramElementCreateService.createConnectionDecorator(connection, true, 0.9, true); Text targetLabel = graphicAlgorithmService.createText(connectionDecoratorForTargetLabel, addedRelationship.getTargetLabel().getName()); graphicAlgorithmService.setLocation(targetLabel, 0, -1*DISTANCE_FROM_CONNECTION_LINE); targetLabel.setForeground(manageColor(COLOR_TEXT)); @@ -174,6 +174,7 @@ public class RelationshipPattern extends FRaMEDConnectionPattern { EditRelationshipFeature editRelationshipFeature = getEditRelationshipFeature(customContext); if(editRelationshipFeature.canExecute(customContext)) editRelationshipFeature.execute(customContext); + pictogramElementCreateService.createChopboxAnchor(connection); return connection; } @@ -201,8 +202,8 @@ public class RelationshipPattern extends FRaMEDConnectionPattern { public boolean canCreate(ICreateConnectionContext createContext) { Anchor sourceAnchor = createContext.getSourceAnchor(); Anchor targetAnchor = createContext.getTargetAnchor(); - org.framed.iorm.model.Shape sourceShape = ConnectionPatternUtil.getShapeForAnchor(sourceAnchor); - org.framed.iorm.model.Shape targetShape = ConnectionPatternUtil.getShapeForAnchor(targetAnchor); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement targetShape = ConnectionPatternUtil.getModelElementForAnchor(targetAnchor); if(sourceShape != null && targetShape != null) { if(sourceShape.getContainer() == targetShape.getContainer()) { if(sourceShape.getType() == Type.ROLE_TYPE) @@ -223,7 +224,7 @@ public class RelationshipPattern extends FRaMEDConnectionPattern { @Override public boolean canStartConnection(ICreateConnectionContext createContext) { Anchor sourceAnchor = createContext.getSourceAnchor(); - org.framed.iorm.model.Shape sourceShape = ConnectionPatternUtil.getShapeForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); if(sourceShape != null){ if(sourceShape.getType() == Type.ROLE_TYPE) return true; @@ -245,8 +246,8 @@ public class RelationshipPattern extends FRaMEDConnectionPattern { //Step 1 Anchor sourceAnchor = createContext.getSourceAnchor(); Anchor targetAnchor = createContext.getTargetAnchor(); - org.framed.iorm.model.Shape sourceShape = ConnectionPatternUtil.getShapeForAnchor(sourceAnchor); - org.framed.iorm.model.Shape targetShape = ConnectionPatternUtil.getShapeForAnchor(targetAnchor); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement targetShape = ConnectionPatternUtil.getModelElementForAnchor(targetAnchor); //Step 2 Relation newRelationship = OrmFactory.eINSTANCE.createRelation(); diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/AbstractInterRelationshipConstraintPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/AbstractInterRelationshipConstraintPattern.java index 47971f94..cfe3dd3d 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/AbstractInterRelationshipConstraintPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/AbstractInterRelationshipConstraintPattern.java @@ -1,9 +1,109 @@ package org.framed.iorm.ui.pattern.connections.interrelationship; +import org.eclipse.graphiti.features.context.ICreateConnectionContext; +import org.eclipse.graphiti.features.context.impl.AddConnectionContext; +import org.eclipse.graphiti.mm.pictograms.Anchor; +import org.eclipse.graphiti.mm.pictograms.Connection; +import org.framed.iorm.model.OrmFactory; +import org.framed.iorm.model.Relation; +import org.framed.iorm.model.Type; +import org.framed.iorm.ui.literals.LayoutLiterals; import org.framed.iorm.ui.pattern.connections.FRaMEDConnectionPattern; +import org.framed.iorm.ui.util.ConnectionPatternUtil; +//TODO public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnectionPattern { + /** + * the layout integers used to layout the arrowhead of the inheritances gathered from {@link LayoutLiterals} + */ + private static final int ARROWHEAD_LENGTH = LayoutLiterals.ARROWHEAD_LENGTH, + ARROWHEAD_HEIGHT = LayoutLiterals.ARROWHEAD_HEIGHT; - + /** + * Class constructor + */ + public AbstractInterRelationshipConstraintPattern() { + super(); + } + + //create feature + //~~~~~~~~~~~~~~ + /** + * calculates if an inter relationship constraint can be created + * <p> + * returns true if<br> + * (1) target and source connection are not null and<br> + * (2) target and source connection is of valid type and<br> + * (3) source connection container and targets connection container are the same and<br> + * (4) the source connection is not equals the target connection and<br> + * (5) target and source connection are of the same type + * @return if the inter relationship constraint can be added + */ + @Override + public boolean canCreate(ICreateConnectionContext createContext) { + Anchor sourceAnchor = createContext.getSourceAnchor(); + Anchor targetAnchor = createContext.getTargetAnchor(); + org.framed.iorm.model.ModelElement sourceConnection = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement targetConnection = ConnectionPatternUtil.getModelElementForAnchor(targetAnchor); + if(sourceConnection != null && targetConnection != null) { + if(sourceConnection.getContainer() == targetConnection.getContainer() && + !(sourceConnection.equals(targetConnection))) { + if(sourceConnection.getType() == Type.RELATIONSHIP) + if(targetConnection.getType() == sourceConnection.getType()) + return true; + } } + return false; + } + + /** + * checks if a inter relationship constraint can be started from a given source connection + * <p> + * returns true if<br> + * (1) source connection is not null and<br> + * (2) source connection is of valid type + * @return if a inter relationship constraint can be started + */ + @Override + public boolean canStartConnection(ICreateConnectionContext createContext) { + Anchor sourceAnchor = createContext.getSourceAnchor(); + org.framed.iorm.model.ModelElement sourceConnection = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + if(sourceConnection != null){ + if(sourceConnection.getType() == Type.RELATIONSHIP) + return true; + } + return false; + } + + /** + * creates the business object of a inter relationship constraint of the given type using the following steps: + * <p> + * Step 1: get source and target connection<br> + * Step 2: get new inter relationship constraint and add it to the resource of the diagram<br> + * Step 3: set source, target and container of inter relationship constraint<br> + * @param type the type to create a inter relationship constraint of + * @param aircp the sub class calling this operation + */ + public Connection createInterRelationshipConstraint(ICreateConnectionContext createContext, Type type, AbstractInterRelationshipConstraintPattern aircp) { + //Step 1 + Anchor sourceAnchor = createContext.getSourceAnchor(); + Anchor targetAnchor = createContext.getTargetAnchor(); + org.framed.iorm.model.ModelElement sourceConnection = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement targetConnection = ConnectionPatternUtil.getModelElementForAnchor(targetAnchor); + //Step 2 + Relation newInterRelationshipConstraint = OrmFactory.eINSTANCE.createRelation(); + newInterRelationshipConstraint.setType(type); + if(newInterRelationshipConstraint.eResource() != null) getDiagram().eResource().getContents().add(newInterRelationshipConstraint); + //Step 3 + newInterRelationshipConstraint.setContainer(sourceConnection.getContainer()); + sourceConnection.getContainer().getElements().add(newInterRelationshipConstraint); + newInterRelationshipConstraint.setSource(sourceConnection); + newInterRelationshipConstraint.setTarget(targetConnection); + //Step 4 + AddConnectionContext addContext = new AddConnectionContext(sourceAnchor, targetAnchor); + addContext.setNewObject(newInterRelationshipConstraint); + Connection newConnection = null; + if(aircp.canAdd(addContext)) newConnection = (Connection) aircp.add(addContext); + return newConnection; + } } diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipImplicationConstraintPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipImplicationConstraintPattern.java index 8e095427..1583b114 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipImplicationConstraintPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipImplicationConstraintPattern.java @@ -1,5 +1,58 @@ package org.framed.iorm.ui.pattern.connections.interrelationship; +import org.eclipse.graphiti.features.context.ICreateConnectionContext; +import org.eclipse.graphiti.mm.pictograms.Connection; +import org.framed.iorm.model.Type; +import org.framed.iorm.ui.literals.IdentifierLiterals; +import org.framed.iorm.ui.literals.LayoutLiterals; +import org.framed.iorm.ui.literals.NameLiterals; +import org.framed.iorm.ui.pattern.connections.roleconstraint.AbstractRoleConstraintPattern; + +//TODO public class RelationshipImplicationConstraintPattern extends AbstractInterRelationshipConstraintPattern { + /** + * the name of the feature gathered from {@link NameLiterals} + */ + private final String RELATIONSHIP_IMPLICATION_FEATURE_NAME = NameLiterals.RELATIONSHIP_IMPLICATION_FEATURE_NAME; + + /** + * the identifier for the icon of the create feature gathered from {@link IdentifierLiterals} + */ + private static final String IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION; + + /** + * Class constructor + */ + public RelationshipImplicationConstraintPattern() { + super(); + } + + /** + * get method for the features name + * @return the name of the feature + */ + @Override + public String getCreateName() { + return RELATIONSHIP_IMPLICATION_FEATURE_NAME; + } + + /** + * get method for the identifier of the icon for the create feature + * @return the id of the icon + */ + @Override + public String getCreateImageId() { + return IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION; + } + + //create feature + //~~~~~~~~~~~~~~ + /** + * uses the super types equivalent operation to create the relationship implications + */ + @Override + public Connection create(ICreateConnectionContext createContext) { + return super.createInterRelationshipConstraint(createContext, Type.RELATIONSHIP_IMPLICATION, this); + } } diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/intrarelationship/AbstractIntraRelationshipConstraintPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/intrarelationship/AbstractIntraRelationshipConstraintPattern.java index 284b596f..0f0db74b 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/intrarelationship/AbstractIntraRelationshipConstraintPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/intrarelationship/AbstractIntraRelationshipConstraintPattern.java @@ -168,7 +168,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS } /** - * creates the business object of an intra relationship constraint of the given type using the following steps: + * creates the business object of an intra relationship constraint of the given type * @param createContext the context which has a reference to the relationship to add the constraint to * @param type the type of the constraint to add to * @param aircp the sub class calling this operation @@ -184,8 +184,8 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS if(newIntraRelCon.eResource() != null) getDiagram().eResource().getContents().add(newIntraRelCon); model.getElements().add(newIntraRelCon); newIntraRelCon.setContainer(model); - newIntraRelCon.setSource(ConnectionPatternUtil.getShapeForAnchor(sourceAnchor)); - newIntraRelCon.setTarget(ConnectionPatternUtil.getShapeForAnchor(targetAnchor)); + newIntraRelCon.setSource(ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor)); + newIntraRelCon.setTarget(ConnectionPatternUtil.getModelElementForAnchor(targetAnchor)); AddContext addContext = new AddContext(); addContext.setNewObject(newIntraRelCon); addContext.setTargetConnection(targetConnection); diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/AbstractRoleConstraintPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/AbstractRoleConstraintPattern.java index 99128d14..c6136fde 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/AbstractRoleConstraintPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/AbstractRoleConstraintPattern.java @@ -66,8 +66,8 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt public boolean canCreate(ICreateConnectionContext createContext) { Anchor sourceAnchor = createContext.getSourceAnchor(); Anchor targetAnchor = createContext.getTargetAnchor(); - org.framed.iorm.model.Shape sourceShape = ConnectionPatternUtil.getShapeForAnchor(sourceAnchor); - org.framed.iorm.model.Shape targetShape = ConnectionPatternUtil.getShapeForAnchor(targetAnchor); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement targetShape = ConnectionPatternUtil.getModelElementForAnchor(targetAnchor); if(sourceShape != null && targetShape != null) { if(sourceShape.getContainer() == targetShape.getContainer() && !(sourceShape.equals(targetShape))) { @@ -89,7 +89,7 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt @Override public boolean canStartConnection(ICreateConnectionContext createContext) { Anchor sourceAnchor = createContext.getSourceAnchor(); - org.framed.iorm.model.Shape sourceShape = ConnectionPatternUtil.getShapeForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); if(sourceShape != null){ if(sourceShape.getType() == Type.ROLE_TYPE) return true; @@ -111,8 +111,8 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt //Step 1 Anchor sourceAnchor = createContext.getSourceAnchor(); Anchor targetAnchor = createContext.getTargetAnchor(); - org.framed.iorm.model.Shape sourceShape = ConnectionPatternUtil.getShapeForAnchor(sourceAnchor); - org.framed.iorm.model.Shape targetShape = ConnectionPatternUtil.getShapeForAnchor(targetAnchor); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement targetShape = ConnectionPatternUtil.getModelElementForAnchor(targetAnchor); //Step 2 Relation newRoleConstraint = OrmFactory.eINSTANCE.createRelation(); newRoleConstraint.setType(type); diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleEquivalencePattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleEquivalencePattern.java index ae0735a4..30f7997a 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleEquivalencePattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleEquivalencePattern.java @@ -104,7 +104,7 @@ public class RoleEquivalencePattern extends AbstractRoleConstraintPattern { Anchor sourceAnchor = addConnectionContext.getSourceAnchor(); Anchor targetAnchor = addConnectionContext.getTargetAnchor(); //Step 1 - Connection connection = pictogramElementCreateSerive.createFreeFormConnection(getDiagram()); + Connection connection = pictogramElementCreateService.createFreeFormConnection(getDiagram()); connection.setStart(sourceAnchor); connection.setEnd(targetAnchor); Polyline polyline = graphicAlgorithmService.createPolyline(connection); @@ -113,7 +113,7 @@ public class RoleEquivalencePattern extends AbstractRoleConstraintPattern { polyline.setLineWidth(2); //Step2 ConnectionDecorator connectionDecoratorTarget; - connectionDecoratorTarget = pictogramElementCreateSerive.createConnectionDecorator(connection, false, 1.0, true); + connectionDecoratorTarget = pictogramElementCreateService.createConnectionDecorator(connection, false, 1.0, true); int pointsTarget[] = new int[] { -1*ARROWHEAD_LENGTH, ARROWHEAD_HEIGHT, //Point 1 0, 0, //P2 -1*ARROWHEAD_LENGTH, -1*ARROWHEAD_HEIGHT };//P3 @@ -122,7 +122,7 @@ public class RoleEquivalencePattern extends AbstractRoleConstraintPattern { arrowheadTarget.setBackground(manageColor(COLOR_ARROWHEAD)); PropertyUtil.setShape_IdValue(connectionDecoratorTarget, SHAPE_ID_ROLE_CONSTRAINT_DECORATOR); ConnectionDecorator connectionDecoratorSource; - connectionDecoratorSource = pictogramElementCreateSerive.createConnectionDecorator(connection, false, 0, true); + connectionDecoratorSource = pictogramElementCreateService.createConnectionDecorator(connection, false, 0, true); int pointsSource[] = new int[] { -1*ARROWHEAD_LENGTH, ARROWHEAD_HEIGHT, //Point 1 0, 0, //P2 -1*ARROWHEAD_LENGTH, -1*ARROWHEAD_HEIGHT }; //P3 diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleImplicationPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleImplicationPattern.java index 7cdbc2ef..90daa81f 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleImplicationPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleImplicationPattern.java @@ -104,7 +104,7 @@ public class RoleImplicationPattern extends AbstractRoleConstraintPattern { Anchor sourceAnchor = addConnectionContext.getSourceAnchor(); Anchor targetAnchor = addConnectionContext.getTargetAnchor(); //Step 1 - Connection connection = pictogramElementCreateSerive.createFreeFormConnection(getDiagram()); + Connection connection = pictogramElementCreateService.createFreeFormConnection(getDiagram()); connection.setStart(sourceAnchor); connection.setEnd(targetAnchor); Polyline polyline = graphicAlgorithmService.createPolyline(connection); @@ -113,7 +113,7 @@ public class RoleImplicationPattern extends AbstractRoleConstraintPattern { polyline.setLineWidth(2); //Step2 ConnectionDecorator connectionDecorator; - connectionDecorator = pictogramElementCreateSerive.createConnectionDecorator(connection, false, 1.0, true); + connectionDecorator = pictogramElementCreateService.createConnectionDecorator(connection, false, 1.0, true); int points[] = new int[] { -1*ARROWHEAD_LENGTH, ARROWHEAD_HEIGHT, //Point 1 0, 0, //P2 -1*ARROWHEAD_LENGTH, -1*ARROWHEAD_HEIGHT }; //P3 diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleProhibitionPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleProhibitionPattern.java index cb4e7659..8da15177 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleProhibitionPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/roleconstraint/RoleProhibitionPattern.java @@ -101,7 +101,7 @@ public class RoleProhibitionPattern extends AbstractRoleConstraintPattern { Anchor sourceAnchor = addConnectionContext.getSourceAnchor(); Anchor targetAnchor = addConnectionContext.getTargetAnchor(); //Step 1 - Connection connection = pictogramElementCreateSerive.createFreeFormConnection(getDiagram()); + Connection connection = pictogramElementCreateService.createFreeFormConnection(getDiagram()); connection.setStart(sourceAnchor); connection.setEnd(targetAnchor); Polyline polyline = graphicAlgorithmService.createPolyline(connection); @@ -110,7 +110,7 @@ public class RoleProhibitionPattern extends AbstractRoleConstraintPattern { polyline.setLineWidth(2); //Step2 ConnectionDecorator connectionDecoratorTarget; - connectionDecoratorTarget = pictogramElementCreateSerive.createConnectionDecorator(connection, false, 1.0, true); + connectionDecoratorTarget = pictogramElementCreateService.createConnectionDecorator(connection, false, 1.0, true); int pointsTarget[] = new int[] { 0, ARROWHEAD_HEIGHT, //Point 1 -1*ARROWHEAD_LENGTH, 0, //P2 0, -1*ARROWHEAD_HEIGHT }; //P3 @@ -119,7 +119,7 @@ public class RoleProhibitionPattern extends AbstractRoleConstraintPattern { polylineTarget.setForeground(manageColor(COLOR_CONNECTIONS)); PropertyUtil.setShape_IdValue(connectionDecoratorTarget, SHAPE_ID_ROLE_CONSTRAINT_DECORATOR); ConnectionDecorator connectionDecoratorSource; - connectionDecoratorSource = pictogramElementCreateSerive.createConnectionDecorator(connection, false, 0, true); + connectionDecoratorSource = pictogramElementCreateService.createConnectionDecorator(connection, false, 0, true); int pointsSource[] = new int[] { 0, ARROWHEAD_HEIGHT, //Point 1 -1*ARROWHEAD_LENGTH, 0, //P2 0, -1*ARROWHEAD_HEIGHT }; //P3 diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/FeatureProvider.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/FeatureProvider.java index 16f3db72..f6c69470 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/FeatureProvider.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/FeatureProvider.java @@ -20,6 +20,7 @@ import org.framed.iorm.ui.graphitifeatures.StepInFeature; import org.framed.iorm.ui.graphitifeatures.StepInNewTabFeature; import org.framed.iorm.ui.graphitifeatures.StepOutFeature; import org.framed.iorm.ui.pattern.connections.*; +import org.framed.iorm.ui.pattern.connections.interrelationship.RelationshipImplicationConstraintPattern; import org.framed.iorm.ui.pattern.connections.intrarelationship.AbstractIntraRelationshipConstraintPattern; import org.framed.iorm.ui.pattern.connections.intrarelationship.AcyclicConstraintPattern; import org.framed.iorm.ui.pattern.connections.intrarelationship.CyclicConstraintPattern; @@ -72,6 +73,8 @@ public class FeatureProvider extends DefaultFeatureProviderWithPatterns { addPattern(new IrreflexiveConstraintPattern()); addPattern(new ReflexiveConstraintPattern()); addPattern(new TotalConstraintPattern()); + addConnectionPattern(new RelationshipImplicationConstraintPattern()); + //addConnectionPattern(new RelationshipProhibitionConstraintPattern()); } /** diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ImageProvider.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ImageProvider.java index e50015cb..5504a1bc 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ImageProvider.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ImageProvider.java @@ -36,7 +36,9 @@ public class ImageProvider extends AbstractImageProvider { IMG_ID_FEATURE_ROLEEQUIVALENCE = IdentifierLiterals.IMG_ID_FEATURE_ROLEEQUIVALENCE, IMG_ID_FEATURE_ROLEPROHIBITION = IdentifierLiterals.IMG_ID_FEATURE_ROLEPROHIBITION, IMG_ID_FEATURE_RELATIONSHIP = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP, - IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IdentifierLiterals.IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT; + IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IdentifierLiterals.IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT, + IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION, + IMG_ID_FEATURE_RELATIONSHIP_PROHIBITION = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP_EXCLUSION; /** * the image file paths to icons used for shape create features gathered from {@link URLLiterals} @@ -61,7 +63,9 @@ public class ImageProvider extends AbstractImageProvider { IMG_FILEPATH_FEATURE_ROLEEQUIVALENCE = URLLiterals.IMG_FILEPATH_FEATURE_ROLEEQUIVALENCE, IMG_FILEPATH_FEATURE_ROLEPROHIBITION = URLLiterals.IMG_FILEPATH_FEATURE_ROLEPROHIBITION, IMG_FILEPATH_FEATURE_RELATIONSHIP = URLLiterals.IMG_FILEPATH_FEATURE_RELATIONSHIP, - IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT = URLLiterals.IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT; + IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT = URLLiterals.IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT, + IMG_FILEPATH_FEATURE_RELATIONSHIP_IMPLICATION = URLLiterals.IMG_FILEPATH_FEATURE_RELATIONSHIP_IMPLICATION, + IMG_FILEPATH_FEATURE_RELATIONSHIP_PROHIBTION = URLLiterals.IMG_FILEPATH_FEATURE_RELATIONSHIP_EXCLUSION; /** * links the file paths to image identifiers @@ -85,5 +89,7 @@ public class ImageProvider extends AbstractImageProvider { addImageFilePath(IMG_ID_FEATURE_ROLEPROHIBITION, IMG_FILEPATH_FEATURE_ROLEPROHIBITION); addImageFilePath(IMG_ID_FEATURE_RELATIONSHIP, IMG_FILEPATH_FEATURE_RELATIONSHIP); addImageFilePath(IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT, IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT); + addImageFilePath(IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION, IMG_FILEPATH_FEATURE_RELATIONSHIP_IMPLICATION); + addImageFilePath(IMG_ID_FEATURE_RELATIONSHIP_PROHIBITION, IMG_FILEPATH_FEATURE_RELATIONSHIP_PROHIBTION); } } diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java index 20c9595b..90b67921 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java @@ -60,8 +60,9 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ CYCLIC_FEATURE_NAME = NameLiterals.CYCLIC_FEATURE_NAME, IRREFLEXIVE_FEATURE_NAME = NameLiterals.IRREFLEXIVE_FEATURE_NAME, REFLEXIVE_FEATURE_NAME = NameLiterals.REFLEXIVE_FEATURE_NAME, - TOTAL_FEATURE_NAME = NameLiterals.TOTAL_FEATURE_NAME; - + TOTAL_FEATURE_NAME = NameLiterals.TOTAL_FEATURE_NAME, + RELATIONSHIP_IMPLICATION_FEATURE_NAME = NameLiterals.RELATIONSHIP_IMPLICATION_FEATURE_NAME, + RELATIONSHIP_PROHIBITION_FEATURE_NAME = NameLiterals.RELATIONSHIP_EXCLUSION_FEATURE_NAME; /** * the value for the property diagram kind to identify diagrams belonging to a group or compartment type gathered * from {@link IdentiferLiterals} @@ -131,6 +132,8 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ createFeaturesToHideInTopLevelView.add(IRREFLEXIVE_FEATURE_NAME); createFeaturesToHideInTopLevelView.add(REFLEXIVE_FEATURE_NAME); createFeaturesToHideInTopLevelView.add(TOTAL_FEATURE_NAME); + createFeaturesToHideInTopLevelView.add(RELATIONSHIP_IMPLICATION_FEATURE_NAME); + createFeaturesToHideInTopLevelView.add(RELATIONSHIP_PROHIBITION_FEATURE_NAME); //feature to hide in the compartment view createFeaturesToHideInCompartmentView.add(NATURALTYPE_FEATURE_NAME); createFeaturesToHideInCompartmentView.add(DATATYPE_FEATURE_NAME); diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/util/ConnectionPatternUtil.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/util/ConnectionPatternUtil.java index d544d554..d54a593f 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/util/ConnectionPatternUtil.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/util/ConnectionPatternUtil.java @@ -1,7 +1,6 @@ package org.framed.iorm.ui.util; import org.eclipse.graphiti.mm.pictograms.Anchor; -import org.framed.iorm.model.Shape; /** * This class offers several utility operations mostly used by the graphiti connection patterns. @@ -10,20 +9,19 @@ import org.framed.iorm.model.Shape; public class ConnectionPatternUtil { /** - * helper method to get the {@link Shape} for a given anchor - * @param anchor the anchor that belongs to the shape to get - * @return the shape that has the give anchor + * helper method to get the {@link ModelElement} for a given anchor + * @param anchor the anchor that belongs to the model element to get + * @return the model element that has the give anchor */ - public static org.framed.iorm.model.Shape getShapeForAnchor(Anchor anchor) { + public static org.framed.iorm.model.ModelElement getModelElementForAnchor(Anchor anchor) { Object object = null; if (anchor != null) { object = GeneralUtil.getBusinessObjectForPictogramElement(anchor.getParent()); } if (object != null) { if (object instanceof org.framed.iorm.model.Shape) return (org.framed.iorm.model.Shape) object; + if (object instanceof org.framed.iorm.model.Relation) + return (org.framed.iorm.model.Relation) object; } return null; } - - - } -- GitLab