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

#Commit 26.7 18:20

implemented now visible inter relationship constraints (not fully
implemented)
parent 83665310
No related branches found
No related tags found
No related merge requests found
Showing
with 166 additions and 72 deletions
......@@ -92,6 +92,7 @@ public class EditRelationshipFeature extends AbstractCustomFeature {
int returnCode = editDialog.open();
if(returnCode == Window.OK) {
for(ConnectionDecorator decorator : connection.getConnectionDecorators()) {
if(decorator.getGraphicsAlgorithm() instanceof Text) {
Text text = (Text) decorator.getGraphicsAlgorithm();
if(PropertyUtil.isShape_IdValue(decorator, SHAPE_ID_RELATIONSHIP_NAME_DECORATOR)) {
text.setValue(relationshipValues.get(0));
......@@ -104,8 +105,5 @@ public class EditRelationshipFeature extends AbstractCustomFeature {
if(PropertyUtil.isShape_IdValue(decorator, SHAPE_ID_RELATIONSHIP_TARGET_CARDINALITY_DECORATOR)) {
text.setValue(relationshipValues.get(2));
businessObject.getTargetLabel().setName(relationshipValues.get(2));
}
}
}
}
} } } } }
}
......@@ -207,13 +207,19 @@ public class IdentifierLiterals {
*/
public static final String SHAPE_ID_RELATIONSHIP_NAME_DECORATOR = "shape_rst_name",
SHAPE_ID_RELATIONSHIP_SOURCE_CARDINALITY_DECORATOR = "shape_rst_source_cardinality",
SHAPE_ID_RELATIONSHIP_TARGET_CARDINALITY_DECORATOR = "shape_rst_target_cardinality";
SHAPE_ID_RELATIONSHIP_TARGET_CARDINALITY_DECORATOR = "shape_rst_target_cardinality",
SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR = "shape_rst_anchor";
/**
* identifier used for the connection decorators of the intra relationship constraints
*/
public static final String SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR = "shape_irc_name";
/**
* identifier used for role constraint connection decorators
*/
public static final String SHAPE_ID_INTER_REL_CON = "shape_inter_rel_con";
/**
* identifiers used for role types
* <p>
......
......@@ -7,10 +7,14 @@ import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.features.context.impl.CustomContext;
import org.eclipse.graphiti.features.custom.ICustomFeature;
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;
......@@ -62,7 +66,8 @@ public class RelationshipPattern extends FRaMEDConnectionPattern {
*/
private static final String SHAPE_ID_RELATIONSHIP_NAME_DECORATOR = IdentifierLiterals.SHAPE_ID_RELATIONSHIP_NAME_DECORATOR,
SHAPE_ID_RELATIONSHIP_SOURCE_CARDINALITY_DECORATOR = IdentifierLiterals.SHAPE_ID_RELATIONSHIP_SOURCE_CARDINALITY_DECORATOR,
SHAPE_ID_RELATIONSHIP_TARGET_CARDINALITY_DECORATOR = IdentifierLiterals.SHAPE_ID_RELATIONSHIP_TARGET_CARDINALITY_DECORATOR;
SHAPE_ID_RELATIONSHIP_TARGET_CARDINALITY_DECORATOR = IdentifierLiterals.SHAPE_ID_RELATIONSHIP_TARGET_CARDINALITY_DECORATOR,
SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR = IdentifierLiterals.SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR;
/**
* the color values used for the polyline and the texts of the relationship gathered from {@link LayoutLiterals}
......@@ -124,6 +129,7 @@ public class RelationshipPattern extends FRaMEDConnectionPattern {
* 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
*/
......@@ -146,35 +152,47 @@ public class RelationshipPattern extends FRaMEDConnectionPattern {
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 =
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 =
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));
PropertyUtil.setShape_IdValue(connectionDecoratorForTargetLabel, SHAPE_ID_RELATIONSHIP_TARGET_CARDINALITY_DECORATOR);
//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
link(connection, addedRelationship);
link(connectionDecoratorForName, addedRelationship);
link(connectionDecoratorForSourceLabel, addedRelationship);
link(connectionDecoratorForTargetLabel, addedRelationship);
link(connectionDecoratorForAnchor, addedRelationship);
//TODO
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
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);
pictogramElementCreateService.createChopboxAnchor(connection);
return connection;
}
......
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.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.util.IColorConstant;
import org.framed.iorm.model.OrmFactory;
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.LayoutLiterals;
import org.framed.iorm.ui.pattern.connections.FRaMEDConnectionPattern;
import org.framed.iorm.ui.util.ConnectionPatternUtil;
......@@ -14,12 +18,22 @@ import org.framed.iorm.ui.util.ConnectionPatternUtil;
//TODO
public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnectionPattern {
//TODO
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;
/**
* the layout integers used to layout the arrowhead of the inheritances gathered from {@link LayoutLiterals}
*/
private static final int ARROWHEAD_LENGTH = LayoutLiterals.ARROWHEAD_LENGTH,
protected final int ARROWHEAD_LENGTH = LayoutLiterals.ARROWHEAD_LENGTH,
ARROWHEAD_HEIGHT = LayoutLiterals.ARROWHEAD_HEIGHT;
/**
* the color values used for the polyline and the arrowhead gathered from {@link LayoutLiterals}
*/
protected final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS,
COLOR_ARROWHEAD = LayoutLiterals.COLOR_ARROWHEAD;
/**
* Class constructor
*/
......@@ -27,6 +41,24 @@ public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnection
super();
}
//add feature
//~~~~~~~~~~~
/**
* calculates if a inter relationship constraint can be added to the pictogram diagram
* <p>
* returns true if the business object is a inter relationship constraint of the given type
* @return if an inter relationship constraint can be added
*/
public boolean canAddInterRelationshipConstraint(IAddContext addContext, Type type) {
if(addContext.getNewObject() instanceof Relation) {
Relation relation = (Relation) addContext.getNewObject();
if(relation.getType() == type) {
return true;
}
}
return false;
}
//create feature
//~~~~~~~~~~~~~~
/**
......
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.LayoutLiterals;
import org.framed.iorm.ui.literals.NameLiterals;
import org.framed.iorm.ui.pattern.connections.roleconstraint.AbstractRoleConstraintPattern;
import org.framed.iorm.ui.util.PropertyUtil;
//TODO
public class RelationshipImplicationConstraintPattern extends AbstractInterRelationshipConstraintPattern {
......@@ -46,6 +56,64 @@ public class RelationshipImplicationConstraintPattern extends AbstractInterRelat
return IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION;
}
//add feature
//~~~~~~~~~~~
/**
* uses the super types equivalent operation to calculate if the relationship implications can be added
*/
@Override
public boolean canAdd(IAddContext addContext) {
return canAddInterRelationshipConstraint(addContext, Type.RELATIONSHIP_IMPLICATION);
}
/**
* 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
*/
@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
ConnectionDecorator connectionDecorator;
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
Polygon arrowhead = graphicAlgorithmService.createPolygon(connectionDecorator, points);
arrowhead.setForeground(manageColor(COLOR_CONNECTIONS));
arrowhead.setBackground(manageColor(COLOR_ARROWHEAD));
PropertyUtil.setShape_IdValue(connectionDecorator, SHAPE_ID_INTER_REL_CON);
//Step 3
link(connection, addedRoleImplication);
return connection;
}
//create feature
//~~~~~~~~~~~~~~
/**
......
......@@ -5,10 +5,12 @@ 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.eclipse.graphiti.util.IColorConstant;
import org.framed.iorm.model.OrmFactory;
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.LayoutLiterals;
import org.framed.iorm.ui.pattern.connections.FRaMEDConnectionPattern;
import org.framed.iorm.ui.util.ConnectionPatternUtil;
......@@ -32,6 +34,18 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt
super();
}
/**
* the layout integers used to layout the arrowhead of the role equivalences gathered from {@link LayoutLiterals}
*/
protected static final int ARROWHEAD_LENGTH = LayoutLiterals.ARROWHEAD_LENGTH,
ARROWHEAD_HEIGHT = LayoutLiterals.ARROWHEAD_HEIGHT;
/**
* the color values used for the polyline and the arrowhead gathered from {@link LayoutLiterals}
*/
protected static final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS,
COLOR_ARROWHEAD = LayoutLiterals.COLOR_ARROWHEAD;
//add feature
//~~~~~~~~~~~
/**
......
......@@ -10,11 +10,9 @@ 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.util.IColorConstant;
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.LayoutLiterals;
import org.framed.iorm.ui.literals.NameLiterals;
import org.framed.iorm.ui.util.PropertyUtil;
......@@ -41,18 +39,6 @@ public class RoleEquivalencePattern extends AbstractRoleConstraintPattern {
*/
private static final String IMG_ID_FEATURE_ROLEEQUIVALENCE = IdentifierLiterals.IMG_ID_FEATURE_ROLEEQUIVALENCE;
/**
* 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;
/**
* the color values used for the polyline and the arrowhead of the role equivalences gathered from {@link LayoutLiterals}
*/
private static final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS,
COLOR_ARROWHEAD = LayoutLiterals.COLOR_ARROWHEAD;
/**
* Class constructor
*/
......@@ -78,7 +64,6 @@ public class RoleEquivalencePattern extends AbstractRoleConstraintPattern {
return IMG_ID_FEATURE_ROLEEQUIVALENCE;
}
//add feature
//~~~~~~~~~~~
/**
......@@ -109,7 +94,7 @@ public class RoleEquivalencePattern extends AbstractRoleConstraintPattern {
connection.setEnd(targetAnchor);
Polyline polyline = graphicAlgorithmService.createPolyline(connection);
polyline.setForeground(manageColor(COLOR_CONNECTIONS));
polyline.setLineStyle(LineStyle.DASH);
polyline.setLineStyle(LineStyle.DASHDOT);
polyline.setLineWidth(2);
//Step2
ConnectionDecorator connectionDecoratorTarget;
......
......@@ -10,11 +10,9 @@ 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.util.IColorConstant;
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.LayoutLiterals;
import org.framed.iorm.ui.literals.NameLiterals;
import org.framed.iorm.ui.util.PropertyUtil;
......@@ -41,18 +39,6 @@ public class RoleImplicationPattern extends AbstractRoleConstraintPattern {
*/
private static final String IMG_ID_FEATURE_ROLEIMPLICATION = IdentifierLiterals.IMG_ID_FEATURE_ROLEIMPLICATION;
/**
* the layout integers used to layout the arrowhead of the role equivalences gathered from {@link LayoutLiterals}
*/
private static final int ARROWHEAD_LENGTH = LayoutLiterals.ARROWHEAD_LENGTH,
ARROWHEAD_HEIGHT = LayoutLiterals.ARROWHEAD_HEIGHT;
/**
* the color values used for the polyline and the arrowhead of role equivalences gathered from {@link LayoutLiterals}
*/
private static final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS,
COLOR_ARROWHEAD = LayoutLiterals.COLOR_ARROWHEAD;
/**
* Class constructor
*/
......
......@@ -9,11 +9,9 @@ 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.util.IColorConstant;
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.LayoutLiterals;
import org.framed.iorm.ui.literals.NameLiterals;
import org.framed.iorm.ui.util.PropertyUtil;
......@@ -40,17 +38,6 @@ public class RoleProhibitionPattern extends AbstractRoleConstraintPattern {
*/
private static final String IMG_ID_FEATURE_ROLEPROHIBITION = IdentifierLiterals.IMG_ID_FEATURE_ROLEPROHIBITION;
/**
* the layout integers used to layout the arrowhead of the role equivalences gathered from {@link LayoutLiterals}
*/
private static final int ARROWHEAD_LENGTH = LayoutLiterals.ARROWHEAD_LENGTH,
ARROWHEAD_HEIGHT = LayoutLiterals.ARROWHEAD_HEIGHT;
/**
* the color values used for the polyline gathered from {@link LayoutLiterals}
*/
private static final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS;
/**
* Class constructor
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment