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

Fixed canStart and canCreate method for roles playing roles.

parent 543aa8cf
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ public class LayoutLiterals {
* (5) the width of the dialog to edit fulfillments
*/
public static final int LENGHT_TEXTFIELD_WIZARD = 250,
HEIGHT_EDIT_RELATIONSHIP_DIALOG = 185,
HEIGHT_EDIT_RELATIONSHIP_DIALOG = 250,//185,
WIDTH_EDIT_RELATIONSHIP_DIALOG = 400,
HEIGHT_EDIT_FULFILLMENT_DIALOG = 300,
WIDTH_EDIT_FULFILLMENT_DIALOG = 400;
......
......@@ -12,6 +12,8 @@ import org.eclipse.graphiti.mm.algorithms.Text;
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.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.util.IColorConstant;
import org.framed.iorm.model.OrmFactory;
......@@ -22,16 +24,19 @@ 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.ConnectionPatternUtil;
import org.framed.iorm.ui.util.DiagramUtil;
import org.framed.iorm.ui.util.GeneralUtil;
import org.framed.iorm.ui.util.PropertyUtil;
/**
* This graphiti pattern is used to work with {@link Relation}s
* of the type {@link Type#FULFILLMENT} in the editor.
* This graphiti pattern is used to work with {@link Relation}s of the type
* {@link Type#FULFILLMENT} in the editor.
* <p>
* It deals with the following aspects of fulfillments:<br>
* (1) creating fulfillments, especially their business object<br>
* (2) adding fulfillments to the diagram, especially their pictogram elements<br>
* (2) adding fulfillments to the diagram, especially their pictogram
* elements<br>
*
* @author Kevin Kassin
*/
public class FulfillmentPattern extends FRaMEDConnectionPattern {
......@@ -47,12 +52,14 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
private final String EDIT_FULFILLMENT_FEATURE_NAME = NameLiterals.EDIT_FULFILLMENT_FEATURE_NAME;
/**
* the identifier for the icon of the create feature gathered from {@link IdentifierLiterals}
* the identifier for the icon of the create feature gathered from
* {@link IdentifierLiterals}
*/
private static final String IMG_ID_FEATURE_FULFILLMENT = IdentifierLiterals.IMG_ID_FEATURE_FULFILLMENT;
/**
* the value for the property shape id for the connection decorator of the fulfillment
* the value for the property shape id for the connection decorator of the
* fulfillment
*/
private static final String SHAPE_ID_FULFILLMENT_ARROWHEAD = IdentifierLiterals.SHAPE_ID_FULFILLMENT_ARROWHEAD,
SHAPE_ID_FULFILLMENT_ROLES = IdentifierLiterals.SHAPE_ID_FULFILLMENT_ROLES;
......@@ -79,6 +86,7 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
/**
* get method for the features name
*
* @return the name of the feature
*/
@Override
......@@ -88,6 +96,7 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
/**
* get method for the identifier of the icon for the create feature
*
* @return the id of the icon
*/
@Override
......@@ -101,6 +110,7 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
* calculates if a fulfillment can be added to the pictogram diagram
* <p>
* returns true if the business object is a fulfillment
*
* @return if a fulfillment can be added
*/
@Override
......@@ -117,7 +127,8 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
* adds the fulfillment 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 and a arrowhead as its graphic algorithm<br>
* Step 2: create the a connection decorator and a arrowhead as its graphic
* algorithm<br>
* Step 3: create the connection decorator for the fulfilled roles<br>
* Step 4: link the pictogram elements and the business objects<br>
* Step 5: opens the wizard to edit the fulfillments referenced roles
......@@ -136,7 +147,8 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
polyline.setForeground(manageColor(COLOR_CONNECTIONS));
polyline.setLineWidth(2);
// Step2
ConnectionDecorator arrowheadShape = pictogramElementCreateService.createConnectionDecorator(connection, false, 1.0, true);
ConnectionDecorator arrowheadShape = pictogramElementCreateService.createConnectionDecorator(connection, false,
1.0, true);
int points[] = new int[] { -1 * FULFILLMENT_ARROWHEAD_LENGTH, FULFILLMENT_ARROWHEAD_HEIGHT, // Point 1
0, 0, // P2
-1 * FULFILLMENT_ARROWHEAD_LENGTH, -1 * FULFILLMENT_ARROWHEAD_HEIGHT }; // P3
......@@ -145,7 +157,8 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
arrowhead.setBackground(manageColor(COLOR_CONNECTIONS));
PropertyUtil.setShape_IdValue(arrowheadShape, SHAPE_ID_FULFILLMENT_ARROWHEAD);
// Step 3
ConnectionDecorator rolesShape = pictogramElementCreateService.createConnectionDecorator(connection, true, 0.8, true);
ConnectionDecorator rolesShape = pictogramElementCreateService.createConnectionDecorator(connection, true, 0.8,
true);
Text roles = graphicAlgorithmService.createText(rolesShape, "");
graphicAlgorithmService.setLocation(roles, DISTANCE_FROM_CONNECTION_LINE, -1 * DISTANCE_FROM_CONNECTION_LINE);
roles.setForeground(manageColor(COLOR_TEXT));
......@@ -160,8 +173,8 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
pictogramElement[0] = connection;
customContext.setPictogramElements(pictogramElement);
ICustomFeature[] customFeatures = getFeatureProvider().getCustomFeatures(customContext);
EditFulfillmentFeature editFulfillmentFeature =
(EditFulfillmentFeature) GeneralUtil.findFeatureByName(customFeatures, EDIT_FULFILLMENT_FEATURE_NAME);
EditFulfillmentFeature editFulfillmentFeature = (EditFulfillmentFeature) GeneralUtil
.findFeatureByName(customFeatures, EDIT_FULFILLMENT_FEATURE_NAME);
if (editFulfillmentFeature.canExecute(customContext))
editFulfillmentFeature.execute(customContext);
return connection;
......@@ -176,6 +189,7 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
* (1) target and source shape are not null and<br>
* (2) target and source shape are of valid types and<br>
* (3) source shapes container and targets shapes container are the same and<br>
*
* @return if fulfillment can be added
*/
@Override
......@@ -186,12 +200,11 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
org.framed.iorm.model.ModelElement targetShape = ConnectionPatternUtil.getModelElementForAnchor(targetAnchor);
if (sourceShape != null && targetShape != null) {
if (sourceShape.getContainer() == targetShape.getContainer()) {
if(sourceShape.getType() == Type.NATURAL_TYPE ||
sourceShape.getType() == Type.DATA_TYPE ||
sourceShape.getType() == Type.COMPARTMENT_TYPE)
//if (sourceShape.getType() == Type.NATURAL_TYPE || sourceShape.getType() == Type.DATA_TYPE || sourceShape.getType() == Type.COMPARTMENT_TYPE)
if (targetShape.getType() == Type.COMPARTMENT_TYPE)
return true;
} }
}
}
return false;
}
......@@ -201,6 +214,7 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
* returns true if<br>
* (1) source shape is not null and<br>
* (2) source shape is of valid type
*
* @return if fulfillment can be started
*/
@Override
......@@ -208,9 +222,10 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
Anchor sourceAnchor = createContext.getSourceAnchor();
org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor);
if (sourceShape != null) {
if(sourceShape.getType() == Type.NATURAL_TYPE ||
sourceShape.getType() == Type.DATA_TYPE ||
sourceShape.getType() == Type.COMPARTMENT_TYPE)
if (sourceShape.getType() == Type.NATURAL_TYPE || sourceShape.getType() == Type.DATA_TYPE
|| sourceShape.getType() == Type.COMPARTMENT_TYPE
|| (sourceShape.getType() == Type.ROLE_TYPE && PropertyUtil.isDiagram_KindValue(getDiagram(),
IdentifierLiterals.DIAGRAM_KIND_COMPARTMENTTYPE_DIAGRAM)))
return true;
}
return false;
......@@ -234,7 +249,8 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
// Step 2
Relation newFulfillment = OrmFactory.eINSTANCE.createRelation();
newFulfillment.setType(Type.FULFILLMENT);
if(newFulfillment.eResource() != null) getDiagram().eResource().getContents().add(newFulfillment);
if (newFulfillment.eResource() != null)
getDiagram().eResource().getContents().add(newFulfillment);
// Step 3
newFulfillment.setContainer(sourceShape.getContainer());
sourceShape.getContainer().getElements().add(newFulfillment);
......@@ -244,7 +260,8 @@ public class FulfillmentPattern extends FRaMEDConnectionPattern {
AddConnectionContext addContext = new AddConnectionContext(sourceAnchor, targetAnchor);
addContext.setNewObject(newFulfillment);
Connection newConnection = null;
if(canAdd(addContext)) newConnection = (Connection) add(addContext);
if (canAdd(addContext))
newConnection = (Connection) add(addContext);
return newConnection;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment