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 0600c2bef67bb92b6badb84c68bbc5495e86fccd..18eef98fc72123eb81da8c73b2a5481be5b9de70 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 b6ad421f60dcd1334b0e5a5eab0831e537a5715a..f9442a30ceefd9a07aad5654ee95977b10f379a5 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 cd6403daa39d723b03e7c959ffb3b33b63ec42bf..9ee84ebe90453fb3e2d9e05f0d6a10b5b2799837 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 45dbf50fb710e57aee7595f44cd1a98fb40106e6..c297050736852611a295527e5ae4ddd38ace6b22 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 02d4a7563fa6c685adf83dd39c882af346a31eaf..35a82f882bdb3fca90a8cc7c540a948dd42d17aa 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 fa8b3fedaa2ac5fe80ff51c12648c9f36ddd360d..6944852473aa14a9b4a9e32e22ec04f781a0eb00 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 cfd82213907fa07a6c9d6ad7fc73e47da4b13e57..309ef9643cac788893400dbbe692f231fcdb43c6 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 47971f94875012820a09d5d6c33b5f6da0d520b3..cfe3dd3d90999188f4ee5362b9e0d94fe2756e88 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 8e09542737b03ca66023b72ed2d0af211169efba..1583b11425eed95b671946603d2b9a591bb1bac1 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 284b596faac5b1058936fa4497e7e6379fd86c45..0f0db74b58d66fe326db015f7f6fe33598851c86 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 99128d14f854ea6aa199bfebb24c2c0c8a395831..c6136fde258bb52b986fa87a5f3405597bb45c5b 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 ae0735a44ea43bb8a73e7ab5848ef58706386e5b..30f7997a2f5980efe8758b23b26055ddbf0fb022 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 7cdbc2ef4bff9a1d29df556a561a58fdf5e79d88..90daa81fa7e63755ab9570a488d530f25ba3c70c 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 cb4e76598c418e861b8e97adf7f65a03308ee4a7..8da1517785cfdb428e1eec2ca4a634b8bac53f6f 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 16f3db7288977a0a57b318b4c6d2e45affcea070..f6c6947031307c47f7d8e5fb6de762c6cb231d49 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 e50015cb8ac32ae83693e2e0cc318bd9136136cb..5504a1bc73b3346c1abf26357418709cdafbd3a1 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 20c9595ba4fc3ba4a68a231282a80d6a4c4d3b68..90b67921ba3124d769a34b2ebb6bde8cd4b676c1 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 d544d5546d687fe95cb60ff9a6b5f7f000643e06..d54a593f1dfdd20d69bb51f58774312177386fab 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; } - - - }