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

Added TODOs to fix EditPolicies

parent 18b57e66
No related branches found
No related tags found
No related merge requests found
...@@ -133,7 +133,7 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern { ...@@ -133,7 +133,7 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
if (addContext.getNewObject() instanceof Relation) { if (addContext.getNewObject() instanceof Relation) {
Relation relation = (Relation) addContext.getNewObject(); Relation relation = (Relation) addContext.getNewObject();
if (relation.getType() == Type.FULFILLMENT) 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; return false;
} }
......
...@@ -101,7 +101,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { ...@@ -101,7 +101,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern {
if(oldShape != null && newShape != null) { if(oldShape != null && newShape != null) {
if(oldShape.getContainer() == newShape.getContainer()) { if(oldShape.getContainer() == newShape.getContainer()) {
if(newShape.getType() == oldShape.getType()) { if(newShape.getType() == oldShape.getType()) {
return true; return true; //TODO: Handle by the EditPolicyHandler
} } } } } } } } } }
return false; return false;
} }
...@@ -119,7 +119,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { ...@@ -119,7 +119,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern {
if(addContext.getNewObject() instanceof Relation) { if(addContext.getNewObject() instanceof Relation) {
Relation relation = (Relation) addContext.getNewObject(); Relation relation = (Relation) addContext.getNewObject();
if(relation.getType() == Type.INHERITANCE) 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; return false;
} }
...@@ -178,13 +178,16 @@ public class InheritancePattern extends FRaMEDConnectionPattern { ...@@ -178,13 +178,16 @@ public class InheritancePattern extends FRaMEDConnectionPattern {
Anchor targetAnchor = createContext.getTargetAnchor(); Anchor targetAnchor = createContext.getTargetAnchor();
ModelElement source = UIUtil.getModelElementForAnchor(sourceAnchor); ModelElement source = UIUtil.getModelElementForAnchor(sourceAnchor);
ModelElement target = UIUtil.getModelElementForAnchor(targetAnchor); 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) { 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 sourceShape = (org.framed.iorm.model.Shape) source;
org.framed.iorm.model.Shape targetShape = (org.framed.iorm.model.Shape) target; org.framed.iorm.model.Shape targetShape = (org.framed.iorm.model.Shape) target;
if(sourceShape != null && targetShape != null) { if(sourceShape != null && targetShape != null) {
if(sourceShape.getContainer() == targetShape.getContainer() && if(sourceShape.getContainer() == targetShape.getContainer() && //TODO: Fix this Check using sM == tM
!(sourceShape.equals(targetShape))) { !(sourceShape.equals(targetShape))) { //TODO: Move this check to EditPolicy
if(types.contains(sourceShape.getType())) if(types.contains(sourceShape.getType())) //TODO: Remove these tests and defer them to the EditPolicyHandler
if(targetShape.getType() == sourceShape.getType()) if(targetShape.getType() == sourceShape.getType())
return EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.INHERITANCE); return EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.INHERITANCE);
} } } } } }
...@@ -207,7 +210,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { ...@@ -207,7 +210,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern {
org.framed.iorm.model.Shape sourceShape = (org.framed.iorm.model.Shape) source; org.framed.iorm.model.Shape sourceShape = (org.framed.iorm.model.Shape) source;
if(sourceShape.getFirstSegment() != null && sourceShape.getSecondSegment() !=null) { if(sourceShape.getFirstSegment() != null && sourceShape.getSecondSegment() !=null) {
if(sourceShape != 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 EditPolicyService.getHandler(this.getDiagram()).canStart(createContext, Type.INHERITANCE);
} } } } } }
return false; return false;
......
...@@ -78,7 +78,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC ...@@ -78,7 +78,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC
org.framed.iorm.model.ModelElement newRelation = UIUtil.getModelElementForAnchor(newAnchor); org.framed.iorm.model.ModelElement newRelation = UIUtil.getModelElementForAnchor(newAnchor);
if(newRelation != null) if(newRelation != null)
return (newRelation.getType() == Type.RELATIONSHIP); return (newRelation.getType() == Type.RELATIONSHIP);
return false; return false; //TODO: Call EditPolicyHandler
} }
/** /**
...@@ -110,7 +110,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC ...@@ -110,7 +110,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC
if(addContext.getNewObject() instanceof Relation) { if(addContext.getNewObject() instanceof Relation) {
Relation relation = (Relation) addContext.getNewObject(); Relation relation = (Relation) addContext.getNewObject();
if(relation.getType() == type) { if(relation.getType() == type) {
return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext); return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext); //Type use actual Type
} }
} }
return false; return false;
...@@ -167,7 +167,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC ...@@ -167,7 +167,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC
!(sourceConnection.equals(targetConnection))) { !(sourceConnection.equals(targetConnection))) {
if(sourceConnection.getType() == Type.RELATIONSHIP) if(sourceConnection.getType() == Type.RELATIONSHIP)
if(targetConnection.getType() == sourceConnection.getType()) 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; return false;
} }
...@@ -186,7 +186,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC ...@@ -186,7 +186,7 @@ public abstract class AbstractInterRelationshipConstraintPattern extends FRaMEDC
org.framed.iorm.model.ModelElement sourceConnection = UIUtil.getModelElementForAnchor(sourceAnchor); org.framed.iorm.model.ModelElement sourceConnection = UIUtil.getModelElementForAnchor(sourceAnchor);
if(sourceConnection != null){ if(sourceConnection != null){
if(sourceConnection.getType() == Type.RELATIONSHIP) if(sourceConnection.getType() == Type.RELATIONSHIP)
return true; return true; //TODO: Call EditPolicyHandler
} }
return false; return false;
} }
......
...@@ -165,7 +165,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS ...@@ -165,7 +165,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS
getBusinessObjectForPictogramElement(targetConnection) instanceof Relation) { getBusinessObjectForPictogramElement(targetConnection) instanceof Relation) {
Relation relation = (Relation) getBusinessObjectForPictogramElement(targetConnection); Relation relation = (Relation) getBusinessObjectForPictogramElement(targetConnection);
return relation.getType() == Type.RELATIONSHIP && 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; return false;
} }
...@@ -177,7 +177,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS ...@@ -177,7 +177,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS
* @param aircp the sub class calling this operation * @param aircp the sub class calling this operation
* @return the created business object * @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(); Connection targetConnection = createContext.getTargetConnection();
Relation targetRelation = (Relation) getBusinessObjectForPictogramElement(targetConnection); Relation targetRelation = (Relation) getBusinessObjectForPictogramElement(targetConnection);
Anchor sourceAnchor = targetConnection.getStart(), Anchor sourceAnchor = targetConnection.getStart(),
......
...@@ -55,7 +55,7 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt ...@@ -55,7 +55,7 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt
!(newShape.equals(oldShape))) { !(newShape.equals(oldShape))) {
if(newShape.getType() == Type.ROLE_TYPE) if(newShape.getType() == Type.ROLE_TYPE)
if(oldShape.getType() == newShape.getType()) if(oldShape.getType() == newShape.getType())
return true; return true; //TODO: call EditPolicyHandler
} } } }
return false; return false;
} }
...@@ -72,7 +72,7 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt ...@@ -72,7 +72,7 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt
if(addContext.getNewObject() instanceof Relation) { if(addContext.getNewObject() instanceof Relation) {
Relation relation = (Relation) addContext.getNewObject(); Relation relation = (Relation) addContext.getNewObject();
if(relation.getType() == type) if(relation.getType() == type)
return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext); return EditPolicyService.getHandler(this.getDiagram()).canAdd(addContext,type); //TODO:added Type
} }
return false; return false;
} }
...@@ -91,7 +91,7 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt ...@@ -91,7 +91,7 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt
* @return if the role constraint can be added * @return if the role constraint can be added
*/ */
@Override @Override
public boolean canCreate(ICreateConnectionContext createContext) { public boolean canCreate(ICreateConnectionContext createContext) { //TODO: Better make this Abstract similar to canAddRoleConstraint
Anchor sourceAnchor = createContext.getSourceAnchor(); Anchor sourceAnchor = createContext.getSourceAnchor();
Anchor targetAnchor = createContext.getTargetAnchor(); Anchor targetAnchor = createContext.getTargetAnchor();
org.framed.iorm.model.ModelElement sourceShape = UIUtil.getModelElementForAnchor(sourceAnchor); org.framed.iorm.model.ModelElement sourceShape = UIUtil.getModelElementForAnchor(sourceAnchor);
...@@ -100,8 +100,8 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt ...@@ -100,8 +100,8 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt
if(sourceShape.getContainer() == targetShape.getContainer() && if(sourceShape.getContainer() == targetShape.getContainer() &&
!(sourceShape.equals(targetShape))) { !(sourceShape.equals(targetShape))) {
if(types.contains(sourceShape.getType()) && if(types.contains(sourceShape.getType()) &&
types.contains(targetShape.getType())) types.contains(targetShape.getType())) //TODO: remove types test, as this is handled by EditPolicyHandler
return EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.ROLE_TYPE); return EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.ROLE_TYPE); //TODO: fix this call to actually refere to the Role Constraint
} } } }
return false; return false;
} }
...@@ -119,8 +119,8 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt ...@@ -119,8 +119,8 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt
Anchor sourceAnchor = createContext.getSourceAnchor(); Anchor sourceAnchor = createContext.getSourceAnchor();
org.framed.iorm.model.ModelElement sourceShape = UIUtil.getModelElementForAnchor(sourceAnchor); org.framed.iorm.model.ModelElement sourceShape = UIUtil.getModelElementForAnchor(sourceAnchor);
if(sourceShape != null){ if(sourceShape != null){
if(types.contains(sourceShape.getType())) if(types.contains(sourceShape.getType())) //TODO: Remove this check
return true; return true; //TODO: Call EditPolicyHandler
} }
return false; return false;
} }
......
...@@ -121,6 +121,7 @@ public class EditPolicyHandler { ...@@ -121,6 +121,7 @@ public class EditPolicyHandler {
public boolean canAdd(IAddContext context) { public boolean canAdd(IAddContext context) {
//new Object is either relation or shape //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(); Relation relation = (Relation) context.getNewObject();
Type type = relation.getType(); Type type = relation.getType();
return this.canAdd(context, type); 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