Skip to content
Snippets Groups Projects
Commit c774a67e authored by Thomas's avatar Thomas
Browse files

Added TODOs to fix EditPolicies

parent 18b57e66
Branches
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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(),
......
......@@ -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;
}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment