Skip to content
Snippets Groups Projects
Commit 2b3c8687 authored by Kevin Kassin's avatar Kevin Kassin
Browse files

#Commit 26.7 20:20

documented and refactored code of previous commits,
fixed bugs when deleting relationships and roles,
implemented relationship exclusion
parent b5894cd1
No related branches found
No related tags found
No related merge requests found
Showing
with 347 additions and 157 deletions
......@@ -10,8 +10,11 @@ import org.eclipse.graphiti.features.context.impl.MultiDeleteInfo;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
import org.framed.iorm.model.Relation;
import org.framed.iorm.model.Type;
import org.framed.iorm.ui.literals.IdentifierLiterals;
import org.framed.iorm.ui.providers.FeatureProvider;
import org.framed.iorm.ui.util.ConnectionPatternUtil;
import org.framed.iorm.ui.util.GeneralUtil;
import org.framed.iorm.ui.util.PropertyUtil;
......@@ -27,7 +30,8 @@ public class FRaMEDDeleteConnectionFeature extends DefaultDeleteFeature {
/**
* the identifiers for the connection decorators to delete with when deleting a connection
*/
protected static final String SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR = IdentifierLiterals.SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR;
protected static final String SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR = IdentifierLiterals.SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR,
SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR = IdentifierLiterals.SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR;
/**
* Class constructor
......@@ -53,7 +57,8 @@ public class FRaMEDDeleteConnectionFeature extends DefaultDeleteFeature {
*/
@Override
public void delete(IDeleteContext deleteContext) {
deleteAttachedConstraints(deleteContext);
Relation relation = (Relation) getBusinessObjectForPictogramElement(deleteContext.getPictogramElement());
if(relation.getType() == Type.RELATIONSHIP) deleteAttachedConstraints(deleteContext);
((DeleteContext) deleteContext).setMultiDeleteInfo(new MultiDeleteInfo(false, false, 0));
super.delete(deleteContext);
}
......@@ -62,26 +67,31 @@ public class FRaMEDDeleteConnectionFeature extends DefaultDeleteFeature {
* deletes intra and inter relationship constraints when deleting a relationship using the
* following steps:
* <p>
* Step 1: find intra relationship constraints by iterating over the connection decorators of the
* relationship to delete<br>
* Step 2: TODO
* Step 3: delete the business objects of all found intra and inter relationship constraints
* Step 1: find intra relationship constraints business elements by checking the referenced relations of the relationship
* to delete<br>
* Step 2: find inter relationship constraints pictogram elements by checking the anchor for the pictogram model
* of the relationship to delete
* Step 3: delete the business objects and pictogram elements of all found intra and inter relationship constraints
* @param deleteContext the context with a reference to the relationship to delete
*/
private void deleteAttachedConstraints(IDeleteContext deleteContext) {
List<ConnectionDecorator> decoratorsToDelete = new ArrayList<ConnectionDecorator>();
Connection connection = (Connection) deleteContext.getPictogramElement();
Relation relation = (Relation) getBusinessObjectForPictogramElement(connection);
List<Relation> relationsToDeleteAlso = new ArrayList<Relation>();
List<Connection> connectionsToDeleteAlso = new ArrayList<Connection>();
//Step 1
for(ConnectionDecorator decorator : connection.getConnectionDecorators()) {
if(PropertyUtil.isShape_IdValue(decorator, SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR))
decoratorsToDelete.add(decorator);
}
relationsToDeleteAlso.addAll(relation.getReferencedRelation());
//Step 2
//TODO
//Step 3
for(ConnectionDecorator decorator : decoratorsToDelete) {
deleteBusinessObject(GeneralUtil.getBusinessObjectForPictogramElement(decorator));
}
ConnectionDecorator anchorDecorator =
ConnectionPatternUtil.getConnectionDecoratorByShapeId(connection, SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR);
connectionsToDeleteAlso.addAll(anchorDecorator.getAnchors().get(0).getIncomingConnections());
connectionsToDeleteAlso.addAll(anchorDecorator.getAnchors().get(0).getOutgoingConnections());
//Step 4
for(Relation relationToDeleteAlso : relationsToDeleteAlso) {
deleteBusinessObject(relationToDeleteAlso);
}
for(Connection connectionToDeleteAlso : connectionsToDeleteAlso) {
DeleteContext deleteContextForInterRelCon = new DeleteContext(connectionToDeleteAlso);
delete(deleteContextForInterRelCon);
} }
}
......@@ -10,11 +10,8 @@ import org.eclipse.graphiti.mm.algorithms.Polyline;
import org.eclipse.graphiti.mm.algorithms.Rectangle;
import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.BoxRelativeAnchor;
import org.eclipse.graphiti.mm.pictograms.ChopboxAnchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.FixPointAnchor;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.util.IColorConstant;
import org.framed.iorm.model.NamedElement;
......@@ -126,12 +123,20 @@ public class RelationshipPattern extends FRaMEDConnectionPattern {
/**
* adds the relationship to the pictogram diagram using the following steps:
* <p>
* Step 1: create a connection shape and polyline as its graphic algorithm<br>
* Step 2: create the a connection decorator for the relationships name<br>
* Step 3: create the a connection decorators for the cardinalities<br>
* TODO
* Step 4: link the pictogram elements and the business objects<br>
* Step 5: opens the wizard to edit the relationships name and cardinalities
* Step 1: creates the connection shape and polyline as its graphic algorithm<br>
* Step 2: creates a connection decorator for the relationships name<br>
* Step 3: creates the connection decorators for the cardinalities<br>
* Step 4: creates a connection decorator for the anchor for inter relationship constraints
* in the visual model
* Step 5: link the pictogram elements and the business objects<br>
* Step 6: set the values for the property shape id of all connection decorators
* Step 7: adds the anchor for inter relationship constraints in the business model
* Step 8: opens the wizard to edit the relationships name and cardinalities
* <p>
* Relationships have two different anchors attached to them. One for the inter relationship
* constraint to hook in the pictogram model. This anchor is used in the operation {@link #add}.
* The other is hooked in by inter relationship constraints in business model and is used in the
* operation {@link #create}.
*/
@Override
public PictogramElement add(IAddContext addContext) {
......@@ -158,38 +163,35 @@ public class RelationshipPattern extends FRaMEDConnectionPattern {
Text sourceLabel = graphicAlgorithmService.createText(connectionDecoratorForSourceLabel, addedRelationship.getSourceLabel().getName());
graphicAlgorithmService.setLocation(sourceLabel, 0, -1*DISTANCE_FROM_CONNECTION_LINE);
sourceLabel.setForeground(manageColor(COLOR_TEXT));
ConnectionDecorator connectionDecoratorForTargetLabel =
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));
//Step 4
ConnectionDecorator connectionDecoratorForAnchor =
pictogramElementCreateService.createConnectionDecorator(connection, true, 0.5, true);
Rectangle rectangle = graphicAlgorithmService.createRectangle(connectionDecoratorForAnchor);
graphicAlgorithmService.setSize(rectangle, 1, 1);
//TODO erklren addAnchor graphical model
pictogramElementCreateService.createChopboxAnchor(connectionDecoratorForAnchor);
//Step 4
//Step 5
link(connection, addedRelationship);
link(connectionDecoratorForName, addedRelationship);
link(connectionDecoratorForSourceLabel, addedRelationship);
link(connectionDecoratorForTargetLabel, addedRelationship);
link(connectionDecoratorForAnchor, addedRelationship);
//TODO
//Step 6
PropertyUtil.setShape_IdValue(connectionDecoratorForName, SHAPE_ID_RELATIONSHIP_NAME_DECORATOR);
PropertyUtil.setShape_IdValue(connectionDecoratorForSourceLabel, SHAPE_ID_RELATIONSHIP_SOURCE_CARDINALITY_DECORATOR);
PropertyUtil.setShape_IdValue(connectionDecoratorForTargetLabel, SHAPE_ID_RELATIONSHIP_TARGET_CARDINALITY_DECORATOR);
PropertyUtil.setShape_IdValue(connectionDecoratorForAnchor, SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR);
//Step 5
//Step 7
pictogramElementCreateService.createChopboxAnchor(connection);
//Step 8
CustomContext customContext = new CustomContext();
PictogramElement[] pictogramElement = new PictogramElement[1];
pictogramElement[0] = connection;
customContext.setPictogramElements(pictogramElement);
//TODO erklren CreateAnchor businessmodel
pictogramElementCreateService.createChopboxAnchor(connection);
EditRelationshipFeature editRelationshipFeature = getEditRelationshipFeature(customContext);
if(editRelationshipFeature.canExecute(customContext))
editRelationshipFeature.execute(customContext);
......
package org.framed.iorm.ui.pattern.connections.interrelationship;
import org.eclipse.graphiti.features.context.IAddConnectionContext;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.ICreateConnectionContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.mm.algorithms.Polyline;
import org.eclipse.graphiti.mm.algorithms.styles.LineStyle;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.util.IColorConstant;
import org.framed.iorm.model.OrmFactory;
import org.framed.iorm.model.Relation;
......@@ -14,11 +17,20 @@ import org.framed.iorm.ui.literals.IdentifierLiterals;
import org.framed.iorm.ui.literals.LayoutLiterals;
import org.framed.iorm.ui.pattern.connections.FRaMEDConnectionPattern;
import org.framed.iorm.ui.util.ConnectionPatternUtil;
import org.framed.iorm.ui.util.PropertyUtil;
import org.framed.iorm.ui.pattern.connections.RelationshipPattern; //*import for javadoc link
//TODO
/**
* This is the abstract super class of the patterns for inter relationship contraints. It collects similiar operations
* an attributes of the patterns {@link RelationshipImplicationConstraintPattern} and
* {@link RelationshipExclusionConstraintPattern}.
* @author Kevin Kassin
*/
public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnectionPattern {
//TODO
/**
* values for the property shape id gathered from {@link IdentifierLiterals}
*/
protected final String SHAPE_ID_INTER_REL_CON = IdentifierLiterals.SHAPE_ID_INTER_REL_CON,
SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR = IdentifierLiterals.SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR;
......@@ -59,6 +71,33 @@ public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnection
return false;
}
/**
* executes some tasks of adding an inter relationship constraint
* <p>
* See {@link RelationshipImplicationConstraintPattern#add} for an explanation.
* @param addContext the context with references to the anchors the business model element
* of a inter relationship constraint uses
* @return the created connection
*/
public Connection addConnectionForInterRelationshipConstraint(IAddContext addContext) {
IAddConnectionContext addConnectionContext = (IAddConnectionContext) addContext;
//Step 1
Anchor graphicalSourceAnchor = null,
graphicalTargetAnchor = null;
graphicalSourceAnchor = this.getGraphicalAnchorForBusinessModelAnchor(addConnectionContext.getSourceAnchor());
graphicalTargetAnchor = this.getGraphicalAnchorForBusinessModelAnchor(addConnectionContext.getTargetAnchor());
if(graphicalSourceAnchor == null || graphicalTargetAnchor == null) return null;
//Step 2
Connection connection = pictogramElementCreateService.createFreeFormConnection(getDiagram());
connection.setStart(graphicalSourceAnchor);
connection.setEnd(graphicalTargetAnchor);
Polyline polyline = graphicAlgorithmService.createPolyline(connection);
polyline.setForeground(manageColor(COLOR_CONNECTIONS));
polyline.setLineStyle(LineStyle.DASH);
polyline.setLineWidth(2);
return connection;
}
//create feature
//~~~~~~~~~~~~~~
/**
......@@ -138,4 +177,21 @@ public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnection
if(aircp.canAdd(addContext)) newConnection = (Connection) aircp.add(addContext);
return newConnection;
}
/**
* fetches the anchor used for the pictogram model for a given anchor that is used by a business model element
* of a inter relationship constraint uses
* <p>
* See {@link RelationshipPattern#add} for further informations.
* @param businessModelAnchor the anchor a business model element of a inter relationship constraint uses
* @return the equivalent anchor for the pictogram element of the inter relationship constraint
*/
protected Anchor getGraphicalAnchorForBusinessModelAnchor(Anchor businessModelAnchor) {
Connection connection = (Connection) businessModelAnchor.getParent();
for(ConnectionDecorator connectionDecorator : connection.getConnectionDecorators()) {
if(PropertyUtil.isShape_IdValue(connectionDecorator, SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR))
return connectionDecorator.getAnchors().get(0);
}
return null;
}
}
package org.framed.iorm.ui.pattern.connections.interrelationship;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.ICreateConnectionContext;
import org.eclipse.graphiti.mm.algorithms.Polygon;
import org.eclipse.graphiti.mm.algorithms.Polyline;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.framed.iorm.model.Relation;
import org.framed.iorm.model.Type;
import org.framed.iorm.ui.literals.IdentifierLiterals;
import org.framed.iorm.ui.literals.NameLiterals;
import org.framed.iorm.ui.util.PropertyUtil;
/**
* This graphiti pattern is used to work with {@link Relation}s
* of the type {@link Type#RELATIONSHIP_EXCLUSION} in the editor.
* <p>
* It deals with the following aspects of exclusion inter relationship constraints:<br>
* (1) creating the constraints, especially their business object<br>
* (2) adding the constraints to the diagram, especially their pictogram elements<br>
* <p>
* It is a subclass of {@link AbstractInterRelationshipConstraintPattern} and several operations used here are implemented there.
* @author Kevin Kassin
*/
public class RelationshipExclusionConstraintPattern extends AbstractInterRelationshipConstraintPattern {
/**
* the name of the feature gathered from {@link NameLiterals}
*/
private final String RELATIONSHIP_EXCLUSION_FEATURE_NAME = NameLiterals.RELATIONSHIP_EXCLUSION_FEATURE_NAME;
/**
* the identifier for the icon of the create feature gathered from {@link IdentifierLiterals}
*/
private static final String IMG_ID_FEATURE_RELATIONSHIP_EXCLUSION = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP_EXCLUSION;
/**
* Class constructor
*/
public RelationshipExclusionConstraintPattern() {
super();
}
/**
* get method for the features name
* @return the name of the feature
*/
@Override
public String getCreateName() {
return RELATIONSHIP_EXCLUSION_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_EXCLUSION;
}
//add feature
//~~~~~~~~~~~
/**
* uses the super types equivalent operation to calculate if the relationship exclusion can be added
*/
@Override
public boolean canAdd(IAddContext addContext) {
return canAddInterRelationshipConstraint(addContext, Type.RELATIONSHIP_EXCLUSION);
}
/**
* adds the role equivalences to the pictogram diagram using the following steps:
* <p>
* Step 1: get anchors used to hook in the inter relationship constraint for the pictogram model<br>
* Step 2: create a connection shape and dashed polyline as its graphic algorithm<br>
* Step 3: create the connection decorators and their graphics algorithms<br>
* Step 4: link the pictogram elements and the business objects<br>
* <p>
* Step 1 and 2 are executed by the operation
* {@link AbstractInterRelationshipConstraintPattern#addConnectionForInterRelationshipConstraint}.
*/
@Override
public PictogramElement add(IAddContext addContext) {
Relation addedRoleImplication = (Relation) addContext.getNewObject();
//Step 1 and 2
Connection connection = addConnectionForInterRelationshipConstraint(addContext);
if(connection == null) return null;
//Step 3
ConnectionDecorator connectionDecoratorTarget =
pictogramElementCreateService.createConnectionDecorator(connection, false, 1.0, true);
int points[] = new int[] { 0, ARROWHEAD_HEIGHT, //Point 1
-1*ARROWHEAD_LENGTH, 0, //P2
0, -1*ARROWHEAD_HEIGHT };//P3
Polyline polylineTarget = graphicAlgorithmService.createPolyline(connectionDecoratorTarget, points);
polylineTarget.setLineWidth(2);
polylineTarget.setForeground(manageColor(COLOR_CONNECTIONS));
PropertyUtil.setShape_IdValue(connectionDecoratorTarget, SHAPE_ID_INTER_REL_CON);
ConnectionDecorator connectionDecoratorSource =
pictogramElementCreateService.createConnectionDecorator(connection, false, 0, true);
Polyline polylineSource = graphicAlgorithmService.createPolyline(connectionDecoratorSource, points);
polylineSource.setLineWidth(2);
polylineSource.setForeground(manageColor(COLOR_CONNECTIONS));
PropertyUtil.setShape_IdValue(connectionDecoratorSource, SHAPE_ID_INTER_REL_CON);
//Step 4
link(connection, addedRoleImplication);
return connection;
}
//create feature
//~~~~~~~~~~~~~~
/**
* uses the super types equivalent operation to create the relationship exclusion
*/
@Override
public Connection create(ICreateConnectionContext createContext) {
return super.createInterRelationshipConstraint(createContext, Type.RELATIONSHIP_EXCLUSION, this);
}
}
package org.framed.iorm.ui.pattern.connections.interrelationship;
import org.eclipse.graphiti.datatypes.ILocation;
import org.eclipse.graphiti.features.context.IAddConnectionContext;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.ICreateConnectionContext;
import org.eclipse.graphiti.mm.algorithms.Polygon;
import org.eclipse.graphiti.mm.algorithms.Polyline;
import org.eclipse.graphiti.mm.algorithms.styles.LineStyle;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
import org.framed.iorm.model.Relation;
import org.framed.iorm.model.Type;
import org.framed.iorm.ui.literals.IdentifierLiterals;
import org.framed.iorm.ui.literals.NameLiterals;
import org.framed.iorm.ui.util.PropertyUtil;
//TODO
/**
* This graphiti pattern is used to work with {@link Relation}s
* of the type {@link Type#RELATIONSHIP_IMPLICATION} in the editor.
* <p>
* It deals with the following aspects of implication inter relationship constraints:<br>
* (1) creating the constraints, especially their business object<br>
* (2) adding the constraints to the diagram, especially their pictogram elements<br>
* <p>
* It is a subclass of {@link AbstractInterRelationshipConstraintPattern} and several operations used here are implemented there.
* @author Kevin Kassin
*/
public class RelationshipImplicationConstraintPattern extends AbstractInterRelationshipConstraintPattern {
/**
......@@ -59,7 +63,7 @@ public class RelationshipImplicationConstraintPattern extends AbstractInterRelat
//add feature
//~~~~~~~~~~~
/**
* uses the super types equivalent operation to calculate if the relationship implications can be added
* uses the super types equivalent operation to calculate if the relationship implication can be added
*/
@Override
public boolean canAdd(IAddContext addContext) {
......@@ -69,37 +73,21 @@ public class RelationshipImplicationConstraintPattern extends AbstractInterRelat
/**
* adds the role equivalences to the pictogram diagram using the following steps:
* <p>
* Step 1: create a connection shape and dashed polyline as its graphic algorithm
* Step 2: create the connection decorators and arrowheads as their graphics algorithms
* Step 3: link the pictogram elements and the business objects
* Step 1: get anchors used to hook in the inter relationship constraint for the pictogram model<br>
* Step 2: create a connection shape and dashed polyline as its graphic algorithm<br>
* Step 3: create the connection decorator and an arrowhead as their graphics algorithms<br>
* Step 4: link the pictogram elements and the business objects<br>
* <p>
* Step 1 and 2 are executed by the operation
* {@link AbstractInterRelationshipConstraintPattern#addConnectionForInterRelationshipConstraint}.
*/
@Override
public PictogramElement add(IAddContext addContext) {
IAddConnectionContext addConnectionContext = (IAddConnectionContext) addContext;
Relation addedRoleImplication = (Relation) addContext.getNewObject();
//TEST
Connection sourceConnection = (Connection) addConnectionContext.getSourceAnchor().getParent();
Connection targetConnection = (Connection) addConnectionContext.getTargetAnchor().getParent();
Anchor graphicalSourceAnchor = null,
graphicalTargetAnchor = null;
for(ConnectionDecorator connectionDecorator : sourceConnection.getConnectionDecorators()) {
if(PropertyUtil.isShape_IdValue(connectionDecorator, SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR))
graphicalSourceAnchor = connectionDecorator.getAnchors().get(0);
}
for(ConnectionDecorator connectionDecorator : targetConnection.getConnectionDecorators()) {
if(PropertyUtil.isShape_IdValue(connectionDecorator, SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR))
graphicalTargetAnchor = connectionDecorator.getAnchors().get(0);
}
if(graphicalSourceAnchor == null || graphicalTargetAnchor == null) return null;
//Step 1
Connection connection = pictogramElementCreateService.createFreeFormConnection(getDiagram());
connection.setStart(graphicalSourceAnchor);
connection.setEnd(graphicalTargetAnchor);
Polyline polyline = graphicAlgorithmService.createPolyline(connection);
polyline.setForeground(manageColor(COLOR_CONNECTIONS));
polyline.setLineStyle(LineStyle.DASH);
polyline.setLineWidth(2);
//Step2
//Step 1 and 2
Connection connection = addConnectionForInterRelationshipConstraint(addContext);
if(connection == null) return null;
//Step 3
ConnectionDecorator connectionDecorator;
connectionDecorator = pictogramElementCreateService.createConnectionDecorator(connection, false, 1.0, true);
int points[] = new int[] { -1*ARROWHEAD_LENGTH, ARROWHEAD_HEIGHT, //Point 1
......@@ -109,7 +97,7 @@ public class RelationshipImplicationConstraintPattern extends AbstractInterRelat
arrowhead.setForeground(manageColor(COLOR_CONNECTIONS));
arrowhead.setBackground(manageColor(COLOR_ARROWHEAD));
PropertyUtil.setShape_IdValue(connectionDecorator, SHAPE_ID_INTER_REL_CON);
//Step 3
//Step 4
link(connection, addedRoleImplication);
return connection;
}
......@@ -117,7 +105,7 @@ public class RelationshipImplicationConstraintPattern extends AbstractInterRelat
//create feature
//~~~~~~~~~~~~~~
/**
* uses the super types equivalent operation to create the relationship implications
* uses the super types equivalent operation to create the relationship implication
*/
@Override
public Connection create(ICreateConnectionContext createContext) {
......
......@@ -25,8 +25,8 @@ import org.framed.iorm.ui.util.PropertyUtil;
/**
* This is the abstract super class of the patterns for intra relationship contraints. It collects similiar operations
* of the patterns {@link AcyclicConstraintPattern}, {@link CyclicConstraintPattern}, {@link IrreflexiveConstraintPattern},
* {@link ReflexiveConstraintPattern} and {@link TotalConstraintPattern}.
* and attributes of the patterns {@link AcyclicConstraintPattern}, {@link CyclicConstraintPattern},
* {@link IrreflexiveConstraintPattern}, {@link ReflexiveConstraintPattern} and {@link TotalConstraintPattern}.
* <p>
* This is implemented as shape pattern instead of a connection pattern since its easier for the user to click on a relationship to
* add a constraint. This would not be able if a connection pattern would be used. As a developer this solution is also preferred as
......@@ -176,6 +176,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS
*/
public Object[] createIntraRelationshipConstraint(ICreateContext createContext, Type type, AbstractIntraRelationshipConstraintPattern aircp) {
Connection targetConnection = createContext.getTargetConnection();
Relation targetRelation = (Relation) getBusinessObjectForPictogramElement(targetConnection);
Anchor sourceAnchor = targetConnection.getStart(),
targetAnchor = targetConnection.getEnd();
Relation newIntraRelCon = OrmFactory.eINSTANCE.createRelation();
......@@ -186,6 +187,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS
newIntraRelCon.setContainer(model);
newIntraRelCon.setSource(ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor));
newIntraRelCon.setTarget(ConnectionPatternUtil.getModelElementForAnchor(targetAnchor));
targetRelation.getReferencedRelation().add(newIntraRelCon);
AddContext addContext = new AddContext();
addContext.setNewObject(newIntraRelCon);
addContext.setTargetConnection(targetConnection);
......
......@@ -16,7 +16,7 @@ import org.framed.iorm.ui.util.ConnectionPatternUtil;
/**
* This is the abstract super class of the patterns for role constraint. It collects similiar operations
* of the patterns {@link RoleImplicationPattern}, {@link RoleEquivalencePattern} and
* and attributes of the patterns {@link RoleImplicationPattern}, {@link RoleEquivalencePattern} and
* {@link RoleProhibitionPattern}.
* @author Kevin Kassin
*/
......
......@@ -96,21 +96,18 @@ public class RoleProhibitionPattern extends AbstractRoleConstraintPattern {
polyline.setLineStyle(LineStyle.DASH);
polyline.setLineWidth(2);
//Step2
ConnectionDecorator connectionDecoratorTarget;
connectionDecoratorTarget = pictogramElementCreateService.createConnectionDecorator(connection, false, 1.0, true);
int pointsTarget[] = new int[] { 0, ARROWHEAD_HEIGHT, //Point 1
ConnectionDecorator connectionDecoratorTarget =
pictogramElementCreateService.createConnectionDecorator(connection, false, 1.0, true);
int points[] = new int[] { 0, ARROWHEAD_HEIGHT, //Point 1
-1*ARROWHEAD_LENGTH, 0, //P2
0, -1*ARROWHEAD_HEIGHT }; //P3
Polyline polylineTarget = graphicAlgorithmService.createPolyline(connectionDecoratorTarget, pointsTarget);
Polyline polylineTarget = graphicAlgorithmService.createPolyline(connectionDecoratorTarget, points);
polylineTarget.setLineWidth(2);
polylineTarget.setForeground(manageColor(COLOR_CONNECTIONS));
PropertyUtil.setShape_IdValue(connectionDecoratorTarget, SHAPE_ID_ROLE_CONSTRAINT_DECORATOR);
ConnectionDecorator connectionDecoratorSource;
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
Polyline polylineSource = graphicAlgorithmService.createPolyline(connectionDecoratorSource, pointsSource);
ConnectionDecorator connectionDecoratorSource =
pictogramElementCreateService.createConnectionDecorator(connection, false, 0, true);
Polyline polylineSource = graphicAlgorithmService.createPolyline(connectionDecoratorSource, points);
polylineSource.setLineWidth(2);
polylineSource.setForeground(manageColor(COLOR_CONNECTIONS));
PropertyUtil.setShape_IdValue(connectionDecoratorSource, SHAPE_ID_ROLE_CONSTRAINT_DECORATOR);
......
......@@ -16,6 +16,7 @@ import org.eclipse.graphiti.pattern.AbstractPattern;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.services.IGaService;
import org.eclipse.graphiti.services.IPeCreateService;
import org.framed.iorm.ui.providers.FeatureProvider;
import org.framed.iorm.ui.util.ShapePatternUtil;
/**
......@@ -106,7 +107,8 @@ public abstract class FRaMEDShapePattern extends AbstractPattern {
for(Connection connection : connectionsToDelete) {
DeleteContext connectionDeleteContext = new DeleteContext(connection);
connectionDeleteContext.setMultiDeleteInfo(new MultiDeleteInfo(false, false, 0));
IDeleteFeature deleteFeature = createDeleteFeature(connectionDeleteContext);
IDeleteFeature deleteFeature =
((FeatureProvider) getFeatureProvider()).getDeleteFeatureAdditional(connectionDeleteContext);
deleteFeature.delete(connectionDeleteContext);
} } }
}
......@@ -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.RelationshipExclusionConstraintPattern;
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;
......@@ -74,7 +75,7 @@ public class FeatureProvider extends DefaultFeatureProviderWithPatterns {
addPattern(new ReflexiveConstraintPattern());
addPattern(new TotalConstraintPattern());
addConnectionPattern(new RelationshipImplicationConstraintPattern());
//addConnectionPattern(new RelationshipProhibitionConstraintPattern());
addConnectionPattern(new RelationshipExclusionConstraintPattern());
}
/**
......
......@@ -62,7 +62,7 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{
REFLEXIVE_FEATURE_NAME = NameLiterals.REFLEXIVE_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;
RELATIONSHIP_EXCLUSION_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}
......@@ -133,7 +133,7 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{
createFeaturesToHideInTopLevelView.add(REFLEXIVE_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(TOTAL_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(RELATIONSHIP_IMPLICATION_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(RELATIONSHIP_PROHIBITION_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(RELATIONSHIP_EXCLUSION_FEATURE_NAME);
//feature to hide in the compartment view
createFeaturesToHideInCompartmentView.add(NATURALTYPE_FEATURE_NAME);
createFeaturesToHideInCompartmentView.add(DATATYPE_FEATURE_NAME);
......
package org.framed.iorm.ui.util;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
/**
* This class offers several utility operations mostly used by the graphiti connection patterns.
......@@ -24,4 +26,13 @@ public class ConnectionPatternUtil {
}
return null;
}
//TODO
public static ConnectionDecorator getConnectionDecoratorByShapeId(Connection connection, String SHAPE_ID) {
for(ConnectionDecorator decorator : connection.getConnectionDecorators()) {
if(PropertyUtil.isShape_IdValue(decorator,SHAPE_ID))
return decorator;
}
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment