From 0dbb7b93958bc498da7bedd30382d57f18366b79 Mon Sep 17 00:00:00 2001 From: Kevin Kassin <KK@Medion-PC> Date: Mon, 24 Jul 2017 00:41:02 +0200 Subject: [PATCH] #Commit 24.07 0:40 half implemented first version of the cyclic relation constraint, renamed old PatternUtil to ShapePatternUtil and created new ConnectionPatternUtil --- .../icon_intrarelationship_constraint.png | Bin 0 -> 196 bytes .../iorm/ui/literals/IdentifierLiterals.java | 4 +- .../framed/iorm/ui/literals/NameLiterals.java | 6 +- .../framed/iorm/ui/literals/TextLiterals.java | 6 +- .../framed/iorm/ui/literals/URLLiterals.java | 6 +- ...actIntraRelationshipConstraintFeature.java | 126 ++++++++++++++++++ .../connections/CyclicConstraintPattern.java | 54 ++++++++ .../connections/InheritancePattern.java | 2 +- .../shapes/CompartmentTypePattern.java | 28 ++-- .../ui/pattern/shapes/DataTypePattern.java | 20 +-- .../ui/pattern/shapes/FRaMEDShapePattern.java | 4 +- .../iorm/ui/pattern/shapes/GroupPattern.java | 18 +-- .../ui/pattern/shapes/NaturalTypePattern.java | 20 +-- .../ui/pattern/shapes/RoleTypePattern.java | 26 ++-- .../iorm/ui/providers/FeatureProvider.java | 2 + .../iorm/ui/providers/ImageProvider.java | 7 +- .../ui/providers/ToolBehaviorProvider.java | 6 +- .../iorm/ui/util/ConnectionPatternUtil.java | 34 +++++ ...PatternUtil.java => ShapePatternUtil.java} | 2 +- 19 files changed, 299 insertions(+), 72 deletions(-) create mode 100644 org.framed.iorm.ui/icons/features/icon_intrarelationship_constraint.png create mode 100644 org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/AbstractIntraRelationshipConstraintFeature.java create mode 100644 org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/CyclicConstraintPattern.java create mode 100644 org.framed.iorm.ui/src/org/framed/iorm/ui/util/ConnectionPatternUtil.java rename org.framed.iorm.ui/src/org/framed/iorm/ui/util/{PatternUtil.java => ShapePatternUtil.java} (98%) diff --git a/org.framed.iorm.ui/icons/features/icon_intrarelationship_constraint.png b/org.framed.iorm.ui/icons/features/icon_intrarelationship_constraint.png new file mode 100644 index 0000000000000000000000000000000000000000..6e9c737ccc9828a3e4c56ff47047bfbed97152ff GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4kiW$hJ4Xg>lqjrSkfJR9T^xl_H+M9WMyDr z;4JWnEM{QfI|Ravq8eTeARQ&H5hcO-X(i=}MX3x0iJ5sNdU>fO3MP66dX_oHb$$#C z3{IXdjv*HQ$v^y64YC9h4J>$9tzVzcz^uTm<kfcKfk}r}gQKr6Z<2wkgO^v9fE3GD qrK1TZvVv@j*#y}_j9&b&XNXwCYa+kdE{cJHfx*+&&t;ucLK6U4S~A%H literal 0 HcmV?d00001 diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/IdentifierLiterals.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/IdentifierLiterals.java index 487e1d9b..cff2334c 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/IdentifierLiterals.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/IdentifierLiterals.java @@ -64,7 +64,9 @@ public class IdentifierLiterals { IMG_ID_FEATURE_ROLEIMPLICATION = IMG_ID_PREFIX + "img_roleimplication", IMG_ID_FEATURE_ROLEEQUIVALENCE = IMG_ID_PREFIX + "img_roleequivalence", IMG_ID_FEATURE_ROLEPROHIBITION = IMG_ID_PREFIX + "img_roleprohibition", - IMG_ID_FEATURE_RELATIONSHIP = IMG_ID_PREFIX + "img_relationship"; + IMG_ID_FEATURE_RELATIONSHIP = IMG_ID_PREFIX + "img_relationship", + IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IMG_ID_PREFIX + "img_intrarelationship_constraint"; + /** * feature model identifier * <p> diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/NameLiterals.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/NameLiterals.java index eb5b7bd9..d7c8062c 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/NameLiterals.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/NameLiterals.java @@ -89,13 +89,15 @@ public class NameLiterals { * (2) the name of the role implication create feature or<br> * (3) the name of the role equivalence create feature or<br> * (4) the name of the role prohibition create feature or<br> - * (5) the name of the relationship create feature + * (5) the name of the relationship create feature or<br> + * (6) the name of the cyclic constraint create feature */ public static final String INHERITANCE_FEATURE_NAME = "Inheritance", ROLEIMPLICATION_FEATURE_NAME = "Role Implication", ROLEEQUIVALENCE_FEATURE_NAME = "Role Eqivalence", ROLEPROHIBITION_FEATURE_NAME = "Role Prohibition", - RELATIONSHIP_FEATURE_NAME = "Relationship"; + RELATIONSHIP_FEATURE_NAME = "Relationship", + CYCLIC_FEATURE_NAME = "Cyclic"; /** * name literals used in the patterns to be identified by the ToolBehaviorProvider diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/TextLiterals.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/TextLiterals.java index 6f20d595..6099b255 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/TextLiterals.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/TextLiterals.java @@ -33,7 +33,7 @@ public class TextLiterals { NAME_ALREADY_USED_COMPARTMENTTYPE = "Another compartment type already has the same name!", DIRECTEDITING_ROLETYPE = "A role types name cant be empty and cant contains spaces. Numbers are allowed but not as first symbol.", NAME_ALREADY_USED_ROLETYPE = "Another role type in this compartment type already has the same name!", - DIRECTEDITING_OCCURRENCE_CONSTRAINT = "The Occurrence Constraint has to be in the form <number/star> or <number>..<number/star>!"; + DIRECTEDITING_OCCURRENCE_CONSTRAINT = "The Occurrence Constraint has to be in the form <number/asterisk> or <number>..<number/asterisk>!"; /** * messages and titles used in the {@link EditRelationshipDialog} as tips when invalid inputs happen @@ -43,9 +43,9 @@ public class TextLiterals { EDITING_RELATIONSHIPS_NAME_ALREADY_USED_TITLE = "Relationships name is already used!", EDITING_RELATIONSHIPS_NAME_ALREADY_USED = "Another relationship already in this compartment type already has the same name!", EDITING_RELATIONSHIPS_SOURCE_CARDINALITY_TITLE = "Relationships source cardinality is invalid!", - EDITING_RELATIONSHIPS_SOURCE_CARDINALITY = "The source cardinality has to be in the form <number/star> or <number>..<number/star>!", + EDITING_RELATIONSHIPS_SOURCE_CARDINALITY = "The source cardinality has to be in the form <number/asterisk> or <number>..<number/asterisk>!", EDITING_RELATIONSHIPS_TARGET_CARDINALITY_TITLE = "Relationships target cardinality is invalid!", - EDITING_RELATIONSHIPS_TARGET_CARDINALITY = "The target cardinality has to be in the form <number/star> or <number>..<number/star>!"; + EDITING_RELATIONSHIPS_TARGET_CARDINALITY = "The target cardinality has to be in the form <number/asterisk> or <number>..<number/asterisk>!"; /** * reason messages used in the <em>updateNeeded</em> operations of the shape pattern diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/URLLiterals.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/URLLiterals.java index 385b05ba..45dbf50f 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/URLLiterals.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/URLLiterals.java @@ -60,11 +60,13 @@ public class URLLiterals { * (2) the file path to the icon for the role implication create feature or<br> * (3) the file path to the icon for the role equivalence create feature or<br> * (4) the file path to the icon for the role prohibtion create feature or<br> - * (5) the file path to the icon for the relationship create feature + * (5) the file path to the icon for the relationship create feature or<br> + * (6) the file path to the icon for the intra realtionship constraints creation features */ public static final String IMG_FILEPATH_FEATURE_INHERITANCE = IMG_FILE_PATH_PREFIX + "inheritance.png", IMG_FILEPATH_FEATURE_ROLEIMPLICATION = IMG_FILE_PATH_PREFIX + "roleimplication.png", IMG_FILEPATH_FEATURE_ROLEEQUIVALENCE = IMG_FILE_PATH_PREFIX + "roleequivalence.png", IMG_FILEPATH_FEATURE_ROLEPROHIBITION = IMG_FILE_PATH_PREFIX + "roleprohibition.png", - IMG_FILEPATH_FEATURE_RELATIONSHIP = IMG_FILE_PATH_PREFIX + "relationship.png"; + IMG_FILEPATH_FEATURE_RELATIONSHIP = IMG_FILE_PATH_PREFIX + "relationship.png", + IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IMG_FILE_PATH_PREFIX + "intrarelationship_constraint.png"; } diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/AbstractIntraRelationshipConstraintFeature.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/AbstractIntraRelationshipConstraintFeature.java new file mode 100644 index 00000000..9425445b --- /dev/null +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/AbstractIntraRelationshipConstraintFeature.java @@ -0,0 +1,126 @@ +package org.framed.iorm.ui.pattern.connections; + +import java.util.List; + +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.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.util.ConnectionPatternUtil; + +//TODO +public abstract class AbstractIntraRelationshipConstraintFeature extends FRaMEDConnectionPattern { + + /** + * the identifier for the icon of the create feature gathered from {@link IdentifierLiterals} + */ + private static final String IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IdentifierLiterals.IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT; + + public AbstractIntraRelationshipConstraintFeature() { + super(); + } + + /** + * get method for the identifier of the common icon for the create features of all + * intra relationship constraints + * @return the id of the icon + */ + @Override + public String getCreateImageId() { + return IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT; + } + + //add feature + //~~~~~~~~~~~ + //TODO + public boolean canAddIntraRelationshipConstraint(IAddContext addContext, Type type) { + if(addContext.getNewObject() instanceof Relation) { + Relation relation = (Relation) addContext.getNewObject(); + if(relation.getType() == type) + return true; + } + return false; + } + + //create feature + //~~~~~~~~~~~~~~ + /** + * calculates if a intra relationship constraint can be created + * <p> + * returns true if<br> + * (1) target and source shape are not null and<br> + * (2) target and source shape is of valid type and<br> + * (3) source shapes container and targets shapes container are the same and<br> + * (4) the source shape is not equals the target shape and<br> + * (5) target and source shape are of the same type + * @return if inheritance can be added + */ + //TODO auftrennen, �bersichtlicher + public boolean canCreate(ICreateConnectionContext createContext) { + Anchor sourceAnchor = createContext.getSourceAnchor(); + Anchor targetAnchor = createContext.getTargetAnchor(); + org.framed.iorm.model.Shape sourceShape = getShapeForAnchor(sourceAnchor); + org.framed.iorm.model.Shape targetShape = getShapeForAnchor(targetAnchor); + if(sourceShape != null && targetShape != null) { + if(sourceShape.getContainer() == targetShape.getContainer() && + !(sourceShape.equals(targetShape))) { + if(sourceShape.getType() == Type.ROLE_TYPE && + targetShape.getType() == sourceShape.getType()) { + List<Relation> commonRelationships = + ConnectionPatternUtil.getRelationsBetweenClassesOrRoles(sourceShape, targetShape, Type.RELATIONSHIP); + if(commonRelationships.size() == 1) + return true; + } } } + return false; + } + + /** + * checks if a intra relationship constraint can be started from a given source shape + * <p> + * returns true if<br> + * (1) source shape is not null and<br> + * (2) source shape is of valid type and<br> + * (3) source shape has at least one relationship + * @return if a intra relationship constraint can be started + */ + @Override + public boolean canStartConnection(ICreateConnectionContext createContext) { + Anchor sourceAnchor = createContext.getSourceAnchor(); + org.framed.iorm.model.Shape sourceShape = getShapeForAnchor(sourceAnchor); + if(sourceShape != null){ + if(sourceShape.getType() == Type.ROLE_TYPE) { + List<Relation> relationships = + ConnectionPatternUtil.getRelationForClassOrRole(sourceShape, Type.RELATIONSHIP); + if(relationships.size() >0) return true; + } } + return false; + } + + public Connection createIntraRelationshipConstraint(ICreateConnectionContext createContext, Type type) { + //Step 1 + Anchor sourceAnchor = createContext.getSourceAnchor(); + Anchor targetAnchor = createContext.getTargetAnchor(); + org.framed.iorm.model.Shape sourceShape = getShapeForAnchor(sourceAnchor); + org.framed.iorm.model.Shape targetShape = getShapeForAnchor(targetAnchor); + //Step 2 + Relation newIntraRelCon = OrmFactory.eINSTANCE.createRelation(); + newIntraRelCon.setType(type); + if(newIntraRelCon.eResource() != null) getDiagram().eResource().getContents().add(newIntraRelCon); + //Step 3 + newIntraRelCon.setContainer(sourceShape.getContainer()); + sourceShape.getContainer().getElements().add(newIntraRelCon); + newIntraRelCon.setSource(sourceShape); + newIntraRelCon.setTarget(targetShape); + //Step 4 + AddConnectionContext addContext = new AddConnectionContext(sourceAnchor, targetAnchor); + addContext.setNewObject(newIntraRelCon); + Connection newConnection = null; + //if(canAdd(addContext)) newConnection = (Connection) add(addContext); + return newConnection; + } +} diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/CyclicConstraintPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/CyclicConstraintPattern.java new file mode 100644 index 00000000..548a7ad5 --- /dev/null +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/CyclicConstraintPattern.java @@ -0,0 +1,54 @@ +package org.framed.iorm.ui.pattern.connections; + +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.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.NameLiterals; + +//TODO +public class CyclicConstraintPattern extends AbstractIntraRelationshipConstraintFeature { + + /** + * the name of the feature gathered from {@link NameLiterals} + */ + private static final String CYCLIC_FEATURE_NAME = NameLiterals.CYCLIC_FEATURE_NAME; + + /** + * Class constructor + */ + public CyclicConstraintPattern() { + super(); + } + + /** + * get method for the features name + * @return the name of the feature + */ + @Override + public String getCreateName() { + return CYCLIC_FEATURE_NAME; + } + + //add feature + //~~~~~~~~~~~ + @Override + public boolean canAdd(IAddContext addContext) { + return canAddIntraRelationshipConstraint(addContext, Type.CYCLIC); + } + + + + //create feature + //~~~~~~~~~~~~~~ + @Override + public Connection create(ICreateConnectionContext createContext) { + return createIntraRelationshipConstraint(createContext, Type.CYCLIC); + } + +} diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/InheritancePattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/InheritancePattern.java index 4d287d19..10c90249 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/InheritancePattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/InheritancePattern.java @@ -145,7 +145,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { * (2) target and source shape is of valid type and<br> * (3) source shapes container and targets shapes container are the same and<br> * (4) the source shape is not equals the target shape and<br> - * (%) target and source shape are of the same type + * (5) target and source shape are of the same type * @return if inheritance can be added */ @Override diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/CompartmentTypePattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/CompartmentTypePattern.java index 04938869..56ae018e 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/CompartmentTypePattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/CompartmentTypePattern.java @@ -52,7 +52,7 @@ import org.framed.iorm.ui.util.DiagramUtil; import org.framed.iorm.ui.util.EditorInputUtil; import org.framed.iorm.ui.util.GeneralUtil; import org.framed.iorm.ui.util.NameUtil; -import org.framed.iorm.ui.util.PatternUtil; +import org.framed.iorm.ui.util.ShapePatternUtil; import org.framed.iorm.ui.util.PropertyUtil; import org.framed.iorm.ui.wizards.RoleModelWizard; @@ -787,19 +787,19 @@ public class CompartmentTypePattern extends FRaMEDShapePattern implements IPatte if(PropertyUtil.isShape_IdValue((Shape) pictogramElement, SHAPE_ID_COMPARTMENTTYPE_TYPEBODY)) { //pictogram name, attributes, operations and elements - String pictogramTypeName = PatternUtil.getNameOfPictogramElement(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_NAME); - List<String> pictogramAttributeNames = PatternUtil.getpictogramAttributeNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_ATTRIBUTECONTAINER); - List<String> pictogramOperationNames = PatternUtil.getpictogramOperationNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_OPERATIONCONTAINER); + String pictogramTypeName = ShapePatternUtil.getNameOfPictogramElement(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_NAME); + List<String> pictogramAttributeNames = ShapePatternUtil.getpictogramAttributeNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_ATTRIBUTECONTAINER); + List<String> pictogramOperationNames = ShapePatternUtil.getpictogramOperationNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_OPERATIONCONTAINER); //model element names in model container of shape - List<String> pictogramElementsNames = PatternUtil.getContentPreviewElementsNames(pictogramElement); + List<String> pictogramElementsNames = ShapePatternUtil.getContentPreviewElementsNames(pictogramElement); //business name and attributes - String businessTypeName = PatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); - List<String> businessAttributeNames = PatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_ATTRIBUTECONTAINER); - List<String> businessOperationNames = PatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_OPERATIONCONTAINER); + String businessTypeName = ShapePatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + List<String> businessAttributeNames = ShapePatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_ATTRIBUTECONTAINER); + List<String> businessOperationNames = ShapePatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_OPERATIONCONTAINER); //at creation no diagram is existing so catch this List<String> modelElementsNames = null; try { - modelElementsNames = PatternUtil.getGroupOrCompartmentTypeElementNames(pictogramElement, getDiagram(), Type.COMPARTMENT_TYPE); + modelElementsNames = ShapePatternUtil.getGroupOrCompartmentTypeElementNames(pictogramElement, getDiagram(), Type.COMPARTMENT_TYPE); } catch(NoDiagramFoundException e) { return Reason.createFalseReason(); } //check for update: different names, different amount of attibutes/ operations @@ -832,9 +832,9 @@ public class CompartmentTypePattern extends FRaMEDShapePattern implements IPatte PictogramElement pictogramElement = updateContext.getPictogramElement(); //business names of natural type, attributes and operations - String businessTypeName = PatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); - List<String> businessAttributeNames = PatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_ATTRIBUTECONTAINER); - List<String> businessOperationNames = PatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_OPERATIONCONTAINER); + String businessTypeName = ShapePatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + List<String> businessAttributeNames = ShapePatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_ATTRIBUTECONTAINER); + List<String> businessOperationNames = ShapePatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_COMPARTMENTTYPE_OPERATIONCONTAINER); //set type name in pictogram model if (pictogramElement instanceof ContainerShape) { @@ -883,7 +883,7 @@ public class CompartmentTypePattern extends FRaMEDShapePattern implements IPatte for(ModelElement modelElement : compartmentModel.getElements()) { if(modelElement instanceof org.framed.iorm.model.Shape) { Shape elementShape = pictogramElementCreateService.createShape(modelContainerShape, true); - Text elementText = graphicAlgorithmService.createText(elementShape, PatternUtil.getGroupOrCompartmentTypeElementText(modelElement)); + Text elementText = graphicAlgorithmService.createText(elementShape, ShapePatternUtil.getGroupOrCompartmentTypeElementText(modelElement)); elementText.setForeground(manageColor(COLOR_TEXT)); PropertyUtil.setShape_IdValue(elementShape, SHAPE_ID_COMPARTMENTTYPE_ELEMENT); counter++; @@ -994,7 +994,7 @@ public class CompartmentTypePattern extends FRaMEDShapePattern implements IPatte for(Shape shape : compartmentDiagram.getChildren()) { if(shape instanceof ContainerShape) { if(PropertyUtil.isShape_IdValue(shape, SHAPE_ID_COMPARTMENTTYPE_CONTAINER)) - innerGroupsOrCompartmentTypesToDelete.add(PatternUtil.getTypeBodyForGroupOrCompartmentContainer((ContainerShape) shape, Type.COMPARTMENT_TYPE)); + innerGroupsOrCompartmentTypesToDelete.add(ShapePatternUtil.getTypeBodyForGroupOrCompartmentContainer((ContainerShape) shape, Type.COMPARTMENT_TYPE)); } } //Step 4 IEditorReference[] openEditors = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences(); diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/DataTypePattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/DataTypePattern.java index 3dd299de..e8f7c142 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/DataTypePattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/DataTypePattern.java @@ -42,7 +42,7 @@ import org.framed.iorm.ui.literals.TextLiterals; import org.framed.iorm.ui.util.DiagramUtil; import org.framed.iorm.ui.util.NameUtil; import org.framed.iorm.ui.util.GeneralUtil; -import org.framed.iorm.ui.util.PatternUtil; +import org.framed.iorm.ui.util.ShapePatternUtil; import org.framed.iorm.ui.util.PropertyUtil; /** @@ -696,13 +696,13 @@ public class DataTypePattern extends FRaMEDShapePattern implements IPattern { if( pictogramElement.getGraphicsAlgorithm() != null && PropertyUtil.isShape_IdValue((Shape) pictogramElement, SHAPE_ID_DATATYPE_TYPEBODY)) { //pictogram name of data type, attributes and operations - String pictogramTypeName = PatternUtil.getNameOfPictogramElement(pictogramElement, SHAPE_ID_DATATYPE_NAME); - List<String> pictogramAttributeNames = PatternUtil.getpictogramAttributeNames(pictogramElement, SHAPE_ID_DATATYPE_ATTRIBUTECONTAINER); - List<String> pictogramOperationNames = PatternUtil.getpictogramOperationNames(pictogramElement, SHAPE_ID_DATATYPE_OPERATIONCONTAINER); + String pictogramTypeName = ShapePatternUtil.getNameOfPictogramElement(pictogramElement, SHAPE_ID_DATATYPE_NAME); + List<String> pictogramAttributeNames = ShapePatternUtil.getpictogramAttributeNames(pictogramElement, SHAPE_ID_DATATYPE_ATTRIBUTECONTAINER); + List<String> pictogramOperationNames = ShapePatternUtil.getpictogramOperationNames(pictogramElement, SHAPE_ID_DATATYPE_OPERATIONCONTAINER); //business name and attributes - String businessTypeName = PatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); - List<String> businessAttributeNames = PatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_DATATYPE_ATTRIBUTECONTAINER); - List<String> businessOperationNames = PatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_DATATYPE_OPERATIONCONTAINER); + String businessTypeName = ShapePatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + List<String> businessAttributeNames = ShapePatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_DATATYPE_ATTRIBUTECONTAINER); + List<String> businessOperationNames = ShapePatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_DATATYPE_OPERATIONCONTAINER); //check for update: different names, different amount of attibutes/ operations if(pictogramTypeName==null || businessTypeName==null) return Reason.createTrueReason(REASON_NAME_NULL); @@ -725,9 +725,9 @@ public class DataTypePattern extends FRaMEDShapePattern implements IPattern { PictogramElement pictogramElement = updateContext.getPictogramElement(); //business names of natural type, attributes and operations - String businessTypeName = PatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); - List<String> businessAttributeNames = PatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_DATATYPE_ATTRIBUTECONTAINER); - List<String> businessOperationNames = PatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_DATATYPE_OPERATIONCONTAINER); + String businessTypeName = ShapePatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + List<String> businessAttributeNames = ShapePatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_DATATYPE_ATTRIBUTECONTAINER); + List<String> businessOperationNames = ShapePatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_DATATYPE_OPERATIONCONTAINER); //set type name in pictogram model if (pictogramElement instanceof ContainerShape) { diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/FRaMEDShapePattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/FRaMEDShapePattern.java index 58366af0..93241657 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/FRaMEDShapePattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/FRaMEDShapePattern.java @@ -16,7 +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.util.PatternUtil; +import org.framed.iorm.ui.util.ShapePatternUtil; /** * This class is an abstract super class for the graphiti shape patterns. @@ -75,7 +75,7 @@ public abstract class FRaMEDShapePattern extends AbstractPattern { * updates the list of the groups or compartment types content of in which an element is added, deleted or renamed */ protected void updateContainingGroupOrCompartmentType() { - ContainerShape groupTypeBodyToUpdate = PatternUtil.getGroupTypeBodyForGroupsDiagram(getDiagram()); + ContainerShape groupTypeBodyToUpdate = ShapePatternUtil.getGroupTypeBodyForGroupsDiagram(getDiagram()); updatePictogramElement(groupTypeBodyToUpdate); } diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/GroupPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/GroupPattern.java index 0fa9c9c9..f801aa7e 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/GroupPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/GroupPattern.java @@ -52,7 +52,7 @@ import org.framed.iorm.ui.util.DiagramUtil; import org.framed.iorm.ui.util.EditorInputUtil; import org.framed.iorm.ui.util.NameUtil; import org.framed.iorm.ui.util.GeneralUtil; -import org.framed.iorm.ui.util.PatternUtil; +import org.framed.iorm.ui.util.ShapePatternUtil; import org.framed.iorm.ui.util.PropertyUtil; import org.framed.iorm.ui.wizards.RoleModelWizard; @@ -631,17 +631,17 @@ public class GroupPattern extends FRaMEDShapePattern implements IPattern { if(PropertyUtil.isShape_IdValue((Shape) pictogramElement, SHAPE_ID_GROUP_TYPEBODY)) { //pictogram name of natural type, attributes and operations - String pictogramTypeName = PatternUtil.getNameOfPictogramElement(pictogramElement, SHAPE_ID_GROUP_NAME); + String pictogramTypeName = ShapePatternUtil.getNameOfPictogramElement(pictogramElement, SHAPE_ID_GROUP_NAME); //business name and attributes - String businessTypeName = PatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + String businessTypeName = ShapePatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); //model element names in groups model //at creation no diagram is existing so catch this List<String> modelElementsNames = null; try { - modelElementsNames = PatternUtil.getGroupOrCompartmentTypeElementNames(pictogramElement, getDiagram(), Type.GROUP); + modelElementsNames = ShapePatternUtil.getGroupOrCompartmentTypeElementNames(pictogramElement, getDiagram(), Type.GROUP); } catch(NoDiagramFoundException e) { return Reason.createFalseReason(); } //model element names in model container of shape - List<String> pictogramElementsNames = PatternUtil.getContentPreviewElementsNames(pictogramElement); + List<String> pictogramElementsNames = ShapePatternUtil.getContentPreviewElementsNames(pictogramElement); //check for update: different names, different amount of attibutes/ operations if(pictogramTypeName==null || businessTypeName==null) return Reason.createTrueReason(REASON_NAME_NULL); @@ -660,7 +660,7 @@ public class GroupPattern extends FRaMEDShapePattern implements IPattern { boolean changed = false; PictogramElement pictogramElement = updateContext.getPictogramElement(); - String businessTypeName = PatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + String businessTypeName = ShapePatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); //set type name in pictogram model if (pictogramElement instanceof ContainerShape) { @@ -685,7 +685,7 @@ public class GroupPattern extends FRaMEDShapePattern implements IPattern { modelContainerShape.getChildren().clear(); for(ModelElement modelElement : groupModel.getElements()) { Shape groupElementShape = pictogramElementCreateService.createShape(modelContainerShape, true); - Text groupElementText = graphicAlgorithmService.createText(groupElementShape, PatternUtil.getGroupOrCompartmentTypeElementText(modelElement)); + Text groupElementText = graphicAlgorithmService.createText(groupElementShape, ShapePatternUtil.getGroupOrCompartmentTypeElementText(modelElement)); groupElementText.setForeground(manageColor(COLOR_TEXT)); PropertyUtil.setShape_IdValue(groupElementShape, SHAPE_ID_GROUP_ELEMENT); } @@ -790,9 +790,9 @@ public class GroupPattern extends FRaMEDShapePattern implements IPattern { for(Shape shape : groupDiagram.getChildren()) { if(shape instanceof ContainerShape) { if(PropertyUtil.isShape_IdValue(shape, SHAPE_ID_GROUP_CONTAINER)) - innerGroupsOrCompartmentTypesToDelete.add(PatternUtil.getTypeBodyForGroupOrCompartmentContainer((ContainerShape) shape, Type.GROUP)); + innerGroupsOrCompartmentTypesToDelete.add(ShapePatternUtil.getTypeBodyForGroupOrCompartmentContainer((ContainerShape) shape, Type.GROUP)); if(PropertyUtil.isShape_IdValue(shape, SHAPE_ID_COMPARTMENTTYPE_CONTAINER)) - innerGroupsOrCompartmentTypesToDelete.add(PatternUtil.getTypeBodyForGroupOrCompartmentContainer((ContainerShape) shape, Type.COMPARTMENT_TYPE)); + innerGroupsOrCompartmentTypesToDelete.add(ShapePatternUtil.getTypeBodyForGroupOrCompartmentContainer((ContainerShape) shape, Type.COMPARTMENT_TYPE)); } } //Step 3 IEditorReference[] openEditors = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences(); diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/NaturalTypePattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/NaturalTypePattern.java index 21348488..75969512 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/NaturalTypePattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/NaturalTypePattern.java @@ -40,7 +40,7 @@ import org.framed.iorm.ui.literals.TextLiterals; import org.framed.iorm.ui.util.DiagramUtil; import org.framed.iorm.ui.util.NameUtil; import org.framed.iorm.ui.util.GeneralUtil; -import org.framed.iorm.ui.util.PatternUtil; +import org.framed.iorm.ui.util.ShapePatternUtil; import org.framed.iorm.ui.util.PropertyUtil; import org.eclipse.graphiti.pattern.AbstractPattern; //*import for javadoc link @@ -688,13 +688,13 @@ public class NaturalTypePattern extends FRaMEDShapePattern implements IPattern { if(pictogramElement.getGraphicsAlgorithm() != null && PropertyUtil.isShape_IdValue((Shape) pictogramElement, SHAPE_ID_NATURALTYPE_TYPEBODY)) { //pictogram name of natural type, attributes and operations - String pictogramTypeName = PatternUtil.getNameOfPictogramElement(pictogramElement, SHAPE_ID_NATURALTYPE_NAME); - List<String> pictogramAttributeNames = PatternUtil.getpictogramAttributeNames(pictogramElement, SHAPE_ID_NATURALTYPE_ATTRIBUTECONTAINER); - List<String> pictogramOperationNames = PatternUtil.getpictogramOperationNames(pictogramElement, SHAPE_ID_NATURALTYPE_OPERATIONCONTAINER); + String pictogramTypeName = ShapePatternUtil.getNameOfPictogramElement(pictogramElement, SHAPE_ID_NATURALTYPE_NAME); + List<String> pictogramAttributeNames = ShapePatternUtil.getpictogramAttributeNames(pictogramElement, SHAPE_ID_NATURALTYPE_ATTRIBUTECONTAINER); + List<String> pictogramOperationNames = ShapePatternUtil.getpictogramOperationNames(pictogramElement, SHAPE_ID_NATURALTYPE_OPERATIONCONTAINER); //business name and attributes - String businessTypeName = PatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); - List<String> businessAttributeNames = PatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_NATURALTYPE_ATTRIBUTECONTAINER); - List<String> businessOperationNames = PatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_NATURALTYPE_OPERATIONCONTAINER); + String businessTypeName = ShapePatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + List<String> businessAttributeNames = ShapePatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_NATURALTYPE_ATTRIBUTECONTAINER); + List<String> businessOperationNames = ShapePatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_NATURALTYPE_OPERATIONCONTAINER); //check for update: different names, different amount of attibutes/ operations if(pictogramTypeName==null || businessTypeName==null) return Reason.createTrueReason(REASON_NAME_NULL); @@ -718,9 +718,9 @@ public class NaturalTypePattern extends FRaMEDShapePattern implements IPattern { PictogramElement pictogramElement = updateContext.getPictogramElement(); //business names of natural type, attributes and operations - String businessTypeName = PatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); - List<String> businessAttributeNames = PatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_NATURALTYPE_ATTRIBUTECONTAINER); - List<String> businessOperationNames = PatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_NATURALTYPE_OPERATIONCONTAINER); + String businessTypeName = ShapePatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + List<String> businessAttributeNames = ShapePatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_NATURALTYPE_ATTRIBUTECONTAINER); + List<String> businessOperationNames = ShapePatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_NATURALTYPE_OPERATIONCONTAINER); //set type name in pictogram model if (pictogramElement instanceof ContainerShape) { diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/RoleTypePattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/RoleTypePattern.java index c2445a3d..c2bb496f 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/RoleTypePattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/shapes/RoleTypePattern.java @@ -43,7 +43,7 @@ import org.framed.iorm.ui.literals.TextLiterals; import org.framed.iorm.ui.util.DiagramUtil; import org.framed.iorm.ui.util.GeneralUtil; import org.framed.iorm.ui.util.NameUtil; -import org.framed.iorm.ui.util.PatternUtil; +import org.framed.iorm.ui.util.ShapePatternUtil; import org.framed.iorm.ui.util.PropertyUtil; public class RoleTypePattern extends FRaMEDShapePattern implements IPattern { @@ -715,15 +715,15 @@ public class RoleTypePattern extends FRaMEDShapePattern implements IPattern { if(PropertyUtil.isShape_IdValue((Shape) pictogramElement, SHAPE_ID_ROLETYPE_TYPEBODY)) { //pictogram name of natural type, attributes and operations, occurrence constraint - String pictogramTypeName = PatternUtil.getNameOfPictogramElement(pictogramElement, SHAPE_ID_ROLETYPE_NAME); - List<String> pictogramAttributeNames = PatternUtil.getpictogramAttributeNames(pictogramElement, SHAPE_ID_ROLETYPE_ATTRIBUTECONTAINER); - List<String> pictogramOperationNames = PatternUtil.getpictogramOperationNames(pictogramElement, SHAPE_ID_ROLETYPE_OPERATIONCONTAINER); - String pictogramOccurrenceConstraint = PatternUtil.getOccurenceConstraintOfPictogramElement(pictogramElement, SHAPE_ID_ROLETYPE_OCCURRENCE_CONSTRAINT); + String pictogramTypeName = ShapePatternUtil.getNameOfPictogramElement(pictogramElement, SHAPE_ID_ROLETYPE_NAME); + List<String> pictogramAttributeNames = ShapePatternUtil.getpictogramAttributeNames(pictogramElement, SHAPE_ID_ROLETYPE_ATTRIBUTECONTAINER); + List<String> pictogramOperationNames = ShapePatternUtil.getpictogramOperationNames(pictogramElement, SHAPE_ID_ROLETYPE_OPERATIONCONTAINER); + String pictogramOccurrenceConstraint = ShapePatternUtil.getOccurenceConstraintOfPictogramElement(pictogramElement, SHAPE_ID_ROLETYPE_OCCURRENCE_CONSTRAINT); //business name and attributes - String businessTypeName = PatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); - List<String> businessAttributeNames = PatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_ROLETYPE_ATTRIBUTECONTAINER); - List<String> businessOperationNames = PatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_ROLETYPE_OPERATIONCONTAINER); - String businessTypeOccurrenceConstraint = PatternUtil.getOccurrenceConstraintOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + String businessTypeName = ShapePatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + List<String> businessAttributeNames = ShapePatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_ROLETYPE_ATTRIBUTECONTAINER); + List<String> businessOperationNames = ShapePatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_ROLETYPE_OPERATIONCONTAINER); + String businessTypeOccurrenceConstraint = ShapePatternUtil.getOccurrenceConstraintOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); //check for update: different names, different amount of attibutes/ operations if(pictogramTypeName==null || businessTypeName==null) return Reason.createTrueReason(REASON_NAME_NULL); @@ -749,10 +749,10 @@ public class RoleTypePattern extends FRaMEDShapePattern implements IPattern { PictogramElement pictogramElement = updateContext.getPictogramElement(); //business names of natural type, attributes and operations - String businessTypeName = PatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); - List<String> businessAttributeNames = PatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_ROLETYPE_ATTRIBUTECONTAINER); - List<String> businessOperationNames = PatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_ROLETYPE_OPERATIONCONTAINER); - String businessTypeOccurrenceConstraint = PatternUtil.getOccurrenceConstraintOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + String businessTypeName = ShapePatternUtil.getNameOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); + List<String> businessAttributeNames = ShapePatternUtil.getBusinessAttributeNames(pictogramElement, SHAPE_ID_ROLETYPE_ATTRIBUTECONTAINER); + List<String> businessOperationNames = ShapePatternUtil.getBusinessOperationNames(pictogramElement, SHAPE_ID_ROLETYPE_OPERATIONCONTAINER); + String businessTypeOccurrenceConstraint = ShapePatternUtil.getOccurrenceConstraintOfBusinessObject(getBusinessObjectForPictogramElement(pictogramElement)); //set type name in pictogram model if (pictogramElement instanceof ContainerShape && diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/FeatureProvider.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/FeatureProvider.java index c3d9a35a..3fd5798c 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/FeatureProvider.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/FeatureProvider.java @@ -19,6 +19,7 @@ import org.framed.iorm.ui.graphitifeatures.FRaMEDMoveConnectionDecoratorFeature; 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.CyclicConstraintPattern; import org.framed.iorm.ui.pattern.connections.InheritancePattern; import org.framed.iorm.ui.pattern.connections.RelationshipPattern; import org.framed.iorm.ui.pattern.connections.RoleEquivalencePattern; @@ -68,6 +69,7 @@ public class FeatureProvider extends DefaultFeatureProviderWithPatterns { addConnectionPattern(new RoleImplicationPattern()); addConnectionPattern(new RoleEquivalencePattern()); addConnectionPattern(new RoleProhibitionPattern()); + addConnectionPattern(new CyclicConstraintPattern()); } /** diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ImageProvider.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ImageProvider.java index c39b63af..e50015cb 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ImageProvider.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ImageProvider.java @@ -35,7 +35,8 @@ public class ImageProvider extends AbstractImageProvider { IMG_ID_FEATURE_ROLEIMPLICATION = IdentifierLiterals.IMG_ID_FEATURE_ROLEIMPLICATION, IMG_ID_FEATURE_ROLEEQUIVALENCE = IdentifierLiterals.IMG_ID_FEATURE_ROLEEQUIVALENCE, IMG_ID_FEATURE_ROLEPROHIBITION = IdentifierLiterals.IMG_ID_FEATURE_ROLEPROHIBITION, - IMG_ID_FEATURE_RELATIONSHIP = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP; + IMG_ID_FEATURE_RELATIONSHIP = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP, + IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IdentifierLiterals.IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT; /** * the image file paths to icons used for shape create features gathered from {@link URLLiterals} @@ -59,7 +60,8 @@ public class ImageProvider extends AbstractImageProvider { IMG_FILEPATH_FEATURE_ROLEIMPLICATION = URLLiterals.IMG_FILEPATH_FEATURE_ROLEIMPLICATION, IMG_FILEPATH_FEATURE_ROLEEQUIVALENCE = URLLiterals.IMG_FILEPATH_FEATURE_ROLEEQUIVALENCE, IMG_FILEPATH_FEATURE_ROLEPROHIBITION = URLLiterals.IMG_FILEPATH_FEATURE_ROLEPROHIBITION, - IMG_FILEPATH_FEATURE_RELATIONSHIP = URLLiterals.IMG_FILEPATH_FEATURE_RELATIONSHIP; + IMG_FILEPATH_FEATURE_RELATIONSHIP = URLLiterals.IMG_FILEPATH_FEATURE_RELATIONSHIP, + IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT = URLLiterals.IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT; /** * links the file paths to image identifiers @@ -82,5 +84,6 @@ public class ImageProvider extends AbstractImageProvider { addImageFilePath(IMG_ID_FEATURE_ROLEEQUIVALENCE, IMG_FILEPATH_FEATURE_ROLEEQUIVALENCE); addImageFilePath(IMG_ID_FEATURE_ROLEPROHIBITION, IMG_FILEPATH_FEATURE_ROLEPROHIBITION); addImageFilePath(IMG_ID_FEATURE_RELATIONSHIP, IMG_FILEPATH_FEATURE_RELATIONSHIP); + addImageFilePath(IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT, IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT); } } diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java index a87bbd25..0b48687b 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java @@ -44,7 +44,8 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ NATURALTYPE_FEATURE_NAME = NameLiterals.NATURALTYPE_FEATURE_NAME, DATATYPE_FEATURE_NAME = NameLiterals.DATATYPE_FEATURE_NAME, GROUP_FEATURE_NAME = NameLiterals.GROUP_FEATURE_NAME, - ROLETYPE_FEATURE_NAME = NameLiterals.ROLETYPE_FEATURE_NAME; + ROLETYPE_FEATURE_NAME = NameLiterals.ROLETYPE_FEATURE_NAME, + CYCLIC_FEATURE_NAME = NameLiterals.CYCLIC_FEATURE_NAME; /** * the name literals for connection create features to remove from the editor palette for the diagram type @@ -230,7 +231,8 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ if(toolEntry.getLabel().equals(ROLEIMPLICATION_FEATURE_NAME) || toolEntry.getLabel().equals(ROLEEQUIVALENCE_FEATURE_NAME) || toolEntry.getLabel().equals(ROLEPROHIBITION_FEATURE_NAME) || - toolEntry.getLabel().equals(RELATIONSHIP_FEATURE_NAME)) + toolEntry.getLabel().equals(RELATIONSHIP_FEATURE_NAME) || + toolEntry.getLabel().equals(CYCLIC_FEATURE_NAME)) toolEntriesConnectionToDelete.add(toolEntry); } for(int i = 0; i < superCompartments[1].getToolEntries().size(); i++) { diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/util/ConnectionPatternUtil.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/util/ConnectionPatternUtil.java new file mode 100644 index 00000000..69feaea7 --- /dev/null +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/util/ConnectionPatternUtil.java @@ -0,0 +1,34 @@ +package org.framed.iorm.ui.util; + +import java.util.ArrayList; +import java.util.List; + +import org.framed.iorm.model.Relation; +import org.framed.iorm.model.Shape; +import org.framed.iorm.model.Type; + +public class ConnectionPatternUtil { + + public static List<Relation> getRelationForClassOrRole(Shape classOrRole, Type type) { + List<Relation> relations = new ArrayList<Relation>(); + for(Relation relation : classOrRole.getIncomingRelations()) { + if(relation.getType() == type) relations.add(relation); + } + for(Relation relation : classOrRole.getOutgoingRelations()) { + if(relation.getType() == type) relations.add(relation); + } + return relations; + } + + public static List<Relation> getRelationsBetweenClassesOrRoles(Shape sourceClassOrRole, Shape targetClassOrRole, Type type) { + List<Relation> commonRelations = new ArrayList<Relation>(); + List<Relation> sourceRelations = getRelationForClassOrRole(sourceClassOrRole, type); + List<Relation> targetRelations = getRelationForClassOrRole(targetClassOrRole, type); + for(Relation relation : targetRelations) { + if(sourceRelations.contains(relation)) + commonRelations.add(relation); + } + return commonRelations; + } + +} diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/util/PatternUtil.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/util/ShapePatternUtil.java similarity index 98% rename from org.framed.iorm.ui/src/org/framed/iorm/ui/util/PatternUtil.java rename to org.framed.iorm.ui/src/org/framed/iorm/ui/util/ShapePatternUtil.java index f437f774..e18e22df 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/util/PatternUtil.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/util/ShapePatternUtil.java @@ -22,7 +22,7 @@ import org.eclipse.graphiti.features.IMappingProvider; //*import for javadoc lin * This class offers several utility operations used by the graphiti patterns. * @author Kevin Kassin */ -public class PatternUtil { +public class ShapePatternUtil { /** * the identifiers for groups pictogram elements gathered from {@link IdentifierLiterals} -- GitLab