diff --git a/org.framed.iorm.ui/core/fulfillment/FulfillmentPattern.java b/org.framed.iorm.ui/core/fulfillment/FulfillmentPattern.java index 10a15622f5f5d55f1212bfe10872ace6db34c98a..caaf0fbac81ee475a9499568e51bd4e957a0368c 100644 --- a/org.framed.iorm.ui/core/fulfillment/FulfillmentPattern.java +++ b/org.framed.iorm.ui/core/fulfillment/FulfillmentPattern.java @@ -133,7 +133,7 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern { if (addContext.getNewObject() instanceof Relation) { Relation relation = (Relation) addContext.getNewObject(); if (relation.getType() == Type.FULFILLMENT) - return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext); + return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext); //TODO: Add actual Type } return false; } diff --git a/org.framed.iorm.ui/core/inheritance/InheritancePattern.java b/org.framed.iorm.ui/core/inheritance/InheritancePattern.java index a2ebd79b8a39df28678f9644cc89e16998248352..75429f1e32727fa4d01416ff4b08074fa736d2d9 100644 --- a/org.framed.iorm.ui/core/inheritance/InheritancePattern.java +++ b/org.framed.iorm.ui/core/inheritance/InheritancePattern.java @@ -101,7 +101,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { if(oldShape != null && newShape != null) { if(oldShape.getContainer() == newShape.getContainer()) { if(newShape.getType() == oldShape.getType()) { - return true; + return true; //TODO: Handle by the EditPolicyHandler } } } } } return false; } @@ -119,7 +119,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { if(addContext.getNewObject() instanceof Relation) { Relation relation = (Relation) addContext.getNewObject(); if(relation.getType() == Type.INHERITANCE) - return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext); + return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext); //Why is the Type not given ,Type.INHERITANCE } return false; } @@ -178,13 +178,16 @@ public class InheritancePattern extends FRaMEDConnectionPattern { Anchor targetAnchor = createContext.getTargetAnchor(); ModelElement source = UIUtil.getModelElementForAnchor(sourceAnchor); ModelElement target = UIUtil.getModelElementForAnchor(targetAnchor); + //TODO: Check whether both elements have the same Model to Create In + Model sM=getModelToCreateIn(source); + Model tM=getModelToCreateIn(target); if(source instanceof org.framed.iorm.model.Shape && target instanceof org.framed.iorm.model.Shape) { org.framed.iorm.model.Shape sourceShape = (org.framed.iorm.model.Shape) source; org.framed.iorm.model.Shape targetShape = (org.framed.iorm.model.Shape) target; if(sourceShape != null && targetShape != null) { - if(sourceShape.getContainer() == targetShape.getContainer() && - !(sourceShape.equals(targetShape))) { - if(types.contains(sourceShape.getType())) + if(sourceShape.getContainer() == targetShape.getContainer() && //TODO: Fix this Check using sM == tM + !(sourceShape.equals(targetShape))) { //TODO: Move this check to EditPolicy + if(types.contains(sourceShape.getType())) //TODO: Remove these tests and defer them to the EditPolicyHandler if(targetShape.getType() == sourceShape.getType()) return EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.INHERITANCE); } } } @@ -207,7 +210,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { org.framed.iorm.model.Shape sourceShape = (org.framed.iorm.model.Shape) source; if(sourceShape.getFirstSegment() != null && sourceShape.getSecondSegment() !=null) { if(sourceShape != null){ - if(types.contains(sourceShape.getType())) + if(types.contains(sourceShape.getType())) //TODO: Remove this tests and defer them to the EditPolicyHandler return EditPolicyService.getHandler(this.getDiagram()).canStart(createContext, Type.INHERITANCE); } } } return false; diff --git a/org.framed.iorm.ui/modules/relationship/inter_relationship_constraints/AbstractInterRelationshipConstraintPattern.java b/org.framed.iorm.ui/modules/relationship/inter_relationship_constraints/AbstractInterRelationshipConstraintPattern.java index 31a68e9dbbcbaccde67bc879558b06a0c5eabf11..b286e42d23f4be0c35474d33d424007300c52073 100644 --- a/org.framed.iorm.ui/modules/relationship/inter_relationship_constraints/AbstractInterRelationshipConstraintPattern.java +++ b/org.framed.iorm.ui/modules/relationship/inter_relationship_constraints/AbstractInterRelationshipConstraintPattern.java @@ -78,7 +78,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC org.framed.iorm.model.ModelElement newRelation = UIUtil.getModelElementForAnchor(newAnchor); if(newRelation != null) return (newRelation.getType() == Type.RELATIONSHIP); - return false; + return false; //TODO: Call EditPolicyHandler } /** @@ -110,7 +110,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC if(addContext.getNewObject() instanceof Relation) { Relation relation = (Relation) addContext.getNewObject(); if(relation.getType() == type) { - return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext); + return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext); //Type use actual Type } } return false; @@ -167,7 +167,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC !(sourceConnection.equals(targetConnection))) { if(sourceConnection.getType() == Type.RELATIONSHIP) if(targetConnection.getType() == sourceConnection.getType()) - return EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.RELATIONSHIP); + return EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.RELATIONSHIP); //Use actual Type to check } } return false; } @@ -186,7 +186,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC org.framed.iorm.model.ModelElement sourceConnection = UIUtil.getModelElementForAnchor(sourceAnchor); if(sourceConnection != null){ if(sourceConnection.getType() == Type.RELATIONSHIP) - return true; + return true; //TODO: Call EditPolicyHandler } return false; } diff --git a/org.framed.iorm.ui/modules/relationship/intra_relationship_constraints/AbstractIntraRelationshipConstraintPattern.java b/org.framed.iorm.ui/modules/relationship/intra_relationship_constraints/AbstractIntraRelationshipConstraintPattern.java index c5d1399eecaa3f236701664e68f597c08b786632..237acf869dd87ac6a9d83f47650a864e7974a9e4 100644 --- a/org.framed.iorm.ui/modules/relationship/intra_relationship_constraints/AbstractIntraRelationshipConstraintPattern.java +++ b/org.framed.iorm.ui/modules/relationship/intra_relationship_constraints/AbstractIntraRelationshipConstraintPattern.java @@ -165,7 +165,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS getBusinessObjectForPictogramElement(targetConnection) instanceof Relation) { Relation relation = (Relation) getBusinessObjectForPictogramElement(targetConnection); return relation.getType() == Type.RELATIONSHIP && - EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.RELATIONSHIP); + EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.RELATIONSHIP); //TODO: Check actual type of Relationship Constraint } return false; } @@ -177,7 +177,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS * @param aircp the sub class calling this operation * @return the created business object */ - public Object[] createIntraRelationshipConstraint(ICreateContext createContext, Type type, AbstractIntraRelationshipConstraintPattern aircp) { + public Object[] createIntraRelationshipConstraint(ICreateContext createContext, Type type, AbstractIntraRelationshipConstraintPattern aircp) { //TODO: Ask Kevin why this fails Connection targetConnection = createContext.getTargetConnection(); Relation targetRelation = (Relation) getBusinessObjectForPictogramElement(targetConnection); Anchor sourceAnchor = targetConnection.getStart(), @@ -194,7 +194,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS addContext.setNewObject(newIntraRelCon); addContext.setTargetConnection(targetConnection); if(aircp.canAdd(addContext)) aircp.add(addContext); - return new Object[] { newIntraRelCon }; + return new Object[] { newIntraRelCon }; } //delete feature diff --git a/org.framed.iorm.ui/modules/roletype/role_constraints/AbstractRoleConstraintPattern.java b/org.framed.iorm.ui/modules/roletype/role_constraints/AbstractRoleConstraintPattern.java index 102743b0564b5a82abfa20a42bf62e427c434852..529874797772041d9739265346334b6eef890576 100644 --- a/org.framed.iorm.ui/modules/roletype/role_constraints/AbstractRoleConstraintPattern.java +++ b/org.framed.iorm.ui/modules/roletype/role_constraints/AbstractRoleConstraintPattern.java @@ -55,7 +55,7 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt !(newShape.equals(oldShape))) { if(newShape.getType() == Type.ROLE_TYPE) if(oldShape.getType() == newShape.getType()) - return true; + return true; //TODO: call EditPolicyHandler } } return false; } @@ -72,7 +72,7 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt if(addContext.getNewObject() instanceof Relation) { Relation relation = (Relation) addContext.getNewObject(); if(relation.getType() == type) - return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext); + return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext,type); //TODO:added Type } return false; } @@ -91,7 +91,7 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt * @return if the role constraint can be added */ @Override - public boolean canCreate(ICreateConnectionContext createContext) { + public boolean canCreate(ICreateConnectionContext createContext) { //TODO: Better make this Abstract similar to canAddRoleConstraint Anchor sourceAnchor = createContext.getSourceAnchor(); Anchor targetAnchor = createContext.getTargetAnchor(); org.framed.iorm.model.ModelElement sourceShape = UIUtil.getModelElementForAnchor(sourceAnchor); @@ -100,8 +100,8 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt if(sourceShape.getContainer() == targetShape.getContainer() && !(sourceShape.equals(targetShape))) { if(types.contains(sourceShape.getType()) && - types.contains(targetShape.getType())) - return EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.ROLE_TYPE); + types.contains(targetShape.getType())) //TODO: remove types test, as this is handled by EditPolicyHandler + return EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.ROLE_TYPE); //TODO: fix this call to actually refere to the Role Constraint } } return false; } @@ -119,8 +119,8 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt Anchor sourceAnchor = createContext.getSourceAnchor(); org.framed.iorm.model.ModelElement sourceShape = UIUtil.getModelElementForAnchor(sourceAnchor); if(sourceShape != null){ - if(types.contains(sourceShape.getType())) - return true; + if(types.contains(sourceShape.getType())) //TODO: Remove this check + return true; //TODO: Call EditPolicyHandler } return false; } diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/EditPolicyHandler.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/EditPolicyHandler.java index 14bf3a96dc5340d230b4a34ae1bef1df449d90d5..96992e8d548e3e5532ff83e9c4092d97704dec69 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/EditPolicyHandler.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/EditPolicyHandler.java @@ -121,6 +121,7 @@ public class EditPolicyHandler { public boolean canAdd(IAddContext context) { //new Object is either relation or shape + //TODO: if there are both options, then account for both or remove this method and use the concrete Type Relation relation = (Relation) context.getNewObject(); Type type = relation.getType(); return this.canAdd(context, type);