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

#Commit 29.7 20:00

fixed bug when reseting the layout on an relationship with intra
relationship constraints,
relationships, inheritances and role constraints now have their source
and target roles as referenced roles also 
parent 5fb01063
No related branches found
No related tags found
No related merge requests found
...@@ -33,18 +33,19 @@ public class ResetLayoutForElementFeature extends AbstractCustomFeature { ...@@ -33,18 +33,19 @@ public class ResetLayoutForElementFeature extends AbstractCustomFeature {
private final String RESET_LAYOUT_FEATURE_NAME = NameLiterals.RESET_LAYOUT_FEATURE_NAME; private final String RESET_LAYOUT_FEATURE_NAME = NameLiterals.RESET_LAYOUT_FEATURE_NAME;
/** /**
* the values for the property shape id of the roles shapes needed to execute this feature * the values for the property shape id needed to execute this feature
* gathered from {@link IdentifierLiterals} * gathered from {@link IdentifierLiterals}
*/ */
private final String SHAPE_ID_ROLETYPE_OCCURRENCE_CONSTRAINT = IdentifierLiterals.SHAPE_ID_ROLETYPE_OCCURRENCE_CONSTRAINT, private final String SHAPE_ID_ROLETYPE_OCCURRENCE_CONSTRAINT = IdentifierLiterals.SHAPE_ID_ROLETYPE_OCCURRENCE_CONSTRAINT,
SHAPE_ID_ROLETYPE_TYPEBODY = IdentifierLiterals.SHAPE_ID_ROLETYPE_TYPEBODY; SHAPE_ID_ROLETYPE_TYPEBODY = IdentifierLiterals.SHAPE_ID_ROLETYPE_TYPEBODY,
SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR = IdentifierLiterals.SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR;
/** /**
* layout integers gathered from {@link LayoutLiterals} * layout integers gathered from {@link LayoutLiterals}
*/ */
private final int DISTANCE_FROM_CONNECTION_LINE = LayoutLiterals.DISTANCE_FROM_CONNECTION_LINE, private final int DISTANCE_FROM_CONNECTION_LINE = LayoutLiterals.DISTANCE_FROM_CONNECTION_LINE,
PUFFER_BETWEEN_ELEMENTS = LayoutLiterals.PUFFER_BETWEEN_ELEMENTS, PUFFER_BETWEEN_ELEMENTS = LayoutLiterals.PUFFER_BETWEEN_ELEMENTS,
HEIGHT_OCCURRENCE_CONSTRAINT = LayoutLiterals.HEIGHT_CONSTRAINT; HEIGHT_CONSTRAINT = LayoutLiterals.HEIGHT_CONSTRAINT;
/** /**
* the graphics algorithm service used to edit graphics algorithms * the graphics algorithm service used to edit graphics algorithms
...@@ -107,10 +108,14 @@ public class ResetLayoutForElementFeature extends AbstractCustomFeature { ...@@ -107,10 +108,14 @@ public class ResetLayoutForElementFeature extends AbstractCustomFeature {
} }
if(connection == null) return; if(connection == null) return;
connection.getBendpoints().clear(); connection.getBendpoints().clear();
int intraRelConsAdded = 0;
for(ConnectionDecorator decorator : connection.getConnectionDecorators()) { for(ConnectionDecorator decorator : connection.getConnectionDecorators()) {
if(PropertyUtil.isShape_IdValue(decorator, SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR)) {
graphicAlgorithmService.setLocation(decorator.getGraphicsAlgorithm(), DISTANCE_FROM_CONNECTION_LINE, intraRelConsAdded*HEIGHT_CONSTRAINT);
intraRelConsAdded++;
} else {
graphicAlgorithmService.setLocation(decorator.getGraphicsAlgorithm(), DISTANCE_FROM_CONNECTION_LINE, -1*DISTANCE_FROM_CONNECTION_LINE); graphicAlgorithmService.setLocation(decorator.getGraphicsAlgorithm(), DISTANCE_FROM_CONNECTION_LINE, -1*DISTANCE_FROM_CONNECTION_LINE);
} } } }
}
/** /**
* executes the feature for the role types * executes the feature for the role types
...@@ -126,10 +131,10 @@ public class ResetLayoutForElementFeature extends AbstractCustomFeature { ...@@ -126,10 +131,10 @@ public class ResetLayoutForElementFeature extends AbstractCustomFeature {
} }
if(typeBodyShape != null && occurenceConstraintShape != null) { if(typeBodyShape != null && occurenceConstraintShape != null) {
RoundedRectangle typeBodyRectangle = (RoundedRectangle) typeBodyShape.getGraphicsAlgorithm(); RoundedRectangle typeBodyRectangle = (RoundedRectangle) typeBodyShape.getGraphicsAlgorithm();
System.out.println(typeBodyRectangle.getX()+typeBodyRectangle.getWidth()/2-HEIGHT_OCCURRENCE_CONSTRAINT/2); System.out.println(typeBodyRectangle.getX()+typeBodyRectangle.getWidth()/2-HEIGHT_CONSTRAINT/2);
graphicAlgorithmService.setLocation(occurenceConstraintShape.getGraphicsAlgorithm(), graphicAlgorithmService.setLocation(occurenceConstraintShape.getGraphicsAlgorithm(),
typeBodyRectangle.getX()+typeBodyRectangle.getWidth()/2-HEIGHT_OCCURRENCE_CONSTRAINT/2, typeBodyRectangle.getX()+typeBodyRectangle.getWidth()/2-HEIGHT_CONSTRAINT/2,
typeBodyRectangle.getY()-HEIGHT_OCCURRENCE_CONSTRAINT-PUFFER_BETWEEN_ELEMENTS); typeBodyRectangle.getY()-HEIGHT_CONSTRAINT-PUFFER_BETWEEN_ELEMENTS);
} }
} }
} }
...@@ -13,6 +13,7 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement; ...@@ -13,6 +13,7 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.util.IColorConstant; import org.eclipse.graphiti.util.IColorConstant;
import org.framed.iorm.model.OrmFactory; import org.framed.iorm.model.OrmFactory;
import org.framed.iorm.model.Relation; import org.framed.iorm.model.Relation;
import org.framed.iorm.model.Shape;
import org.framed.iorm.model.Type; import org.framed.iorm.model.Type;
import org.framed.iorm.ui.literals.IdentifierLiterals; import org.framed.iorm.ui.literals.IdentifierLiterals;
import org.framed.iorm.ui.literals.LayoutLiterals; import org.framed.iorm.ui.literals.LayoutLiterals;
...@@ -195,7 +196,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { ...@@ -195,7 +196,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern {
* <p> * <p>
* Step 1: get source and target shapes<br> * Step 1: get source and target shapes<br>
* Step 2: get new inheritance and add it to the resource of the diagram<br> * Step 2: get new inheritance and add it to the resource of the diagram<br>
* Step 3: set source, target and container of inheritance<br> * Step 3: set source, target, referenced roles and container of inheritance<br>
* Step 4: call add operation of this pattern * Step 4: call add operation of this pattern
*/ */
@Override @Override
...@@ -214,6 +215,10 @@ public class InheritancePattern extends FRaMEDConnectionPattern { ...@@ -214,6 +215,10 @@ public class InheritancePattern extends FRaMEDConnectionPattern {
sourceShape.getContainer().getElements().add(newInheritance); sourceShape.getContainer().getElements().add(newInheritance);
newInheritance.setSource(sourceShape); newInheritance.setSource(sourceShape);
newInheritance.setTarget(targetShape); newInheritance.setTarget(targetShape);
if(sourceShape.getType() == Type.ROLE_TYPE) {
newInheritance.getReferencedRoles().add((Shape) sourceShape);
newInheritance.getReferencedRoles().add((Shape) targetShape);
}
//Step 4 //Step 4
AddConnectionContext addContext = new AddConnectionContext(sourceAnchor, targetAnchor); AddConnectionContext addContext = new AddConnectionContext(sourceAnchor, targetAnchor);
addContext.setNewObject(newInheritance); addContext.setNewObject(newInheritance);
......
...@@ -17,6 +17,7 @@ import org.eclipse.graphiti.util.IColorConstant; ...@@ -17,6 +17,7 @@ import org.eclipse.graphiti.util.IColorConstant;
import org.framed.iorm.model.NamedElement; import org.framed.iorm.model.NamedElement;
import org.framed.iorm.model.OrmFactory; import org.framed.iorm.model.OrmFactory;
import org.framed.iorm.model.Relation; import org.framed.iorm.model.Relation;
import org.framed.iorm.model.Shape;
import org.framed.iorm.model.Type; import org.framed.iorm.model.Type;
import org.framed.iorm.ui.graphitifeatures.EditRelationshipFeature; import org.framed.iorm.ui.graphitifeatures.EditRelationshipFeature;
import org.framed.iorm.ui.literals.IdentifierLiterals; import org.framed.iorm.ui.literals.IdentifierLiterals;
...@@ -257,7 +258,7 @@ public class RelationshipPattern extends FRaMEDConnectionPattern { ...@@ -257,7 +258,7 @@ public class RelationshipPattern extends FRaMEDConnectionPattern {
* <p> * <p>
* Step 1: get source and target shapes<br> * Step 1: get source and target shapes<br>
* Step 2: get new relationship and add it to the resource of the diagram<br> * Step 2: get new relationship and add it to the resource of the diagram<br>
* Step 3: set source, target and container of inheritance<br> * Step 3: set source, target, referenced roles and container of inheritance<br>
* Step 4: sets the cardinalities of the relationship to the standard value <b>*</b><br> * Step 4: sets the cardinalities of the relationship to the standard value <b>*</b><br>
* Step 5: call add operation of this pattern * Step 5: call add operation of this pattern
*/ */
...@@ -279,7 +280,9 @@ public class RelationshipPattern extends FRaMEDConnectionPattern { ...@@ -279,7 +280,9 @@ public class RelationshipPattern extends FRaMEDConnectionPattern {
newRelationship.setContainer(sourceShape.getContainer()); newRelationship.setContainer(sourceShape.getContainer());
sourceShape.getContainer().getElements().add(newRelationship); sourceShape.getContainer().getElements().add(newRelationship);
newRelationship.setSource(sourceShape); newRelationship.setSource(sourceShape);
newRelationship.getReferencedRoles().add((Shape) sourceShape);
newRelationship.setTarget(targetShape); newRelationship.setTarget(targetShape);
newRelationship.getReferencedRoles().add((Shape) targetShape);
//Step 4 //Step 4
NamedElement sourceLabel = OrmFactory.eINSTANCE.createNamedElement(); NamedElement sourceLabel = OrmFactory.eINSTANCE.createNamedElement();
NamedElement targetLabel = OrmFactory.eINSTANCE.createNamedElement(); NamedElement targetLabel = OrmFactory.eINSTANCE.createNamedElement();
......
...@@ -50,9 +50,10 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS ...@@ -50,9 +50,10 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS
private final String SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR = IdentifierLiterals.SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR; private final String SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR = IdentifierLiterals.SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR;
/** /**
* height of the text shape for the intra relationship constraint * layout integers gathered from {@link LayoutLiterals}
*/ */
private final int HEIGHT_CONSTRAINT = LayoutLiterals.HEIGHT_CONSTRAINT; private final int HEIGHT_CONSTRAINT = LayoutLiterals.HEIGHT_CONSTRAINT,
DISTANCE_FROM_CONNECTION_LINE = LayoutLiterals.DISTANCE_FROM_CONNECTION_LINE;
/** /**
* the color values gathered from {@link LayoutLiterals} * the color values gathered from {@link LayoutLiterals}
...@@ -148,7 +149,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS ...@@ -148,7 +149,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS
pictogramElementCreateService.createConnectionDecorator(targetConnection, true, 0.5, true); pictogramElementCreateService.createConnectionDecorator(targetConnection, true, 0.5, true);
Text nameText = graphicAlgorithmService.createText(constraintName, type.getName().toLowerCase()); Text nameText = graphicAlgorithmService.createText(constraintName, type.getName().toLowerCase());
nameText.setForeground(manageColor(COLOR_CONSTRAINT_TEXT)); nameText.setForeground(manageColor(COLOR_CONSTRAINT_TEXT));
graphicAlgorithmService.setLocation(nameText, 0, (numberOfReferencedRelations-1)*HEIGHT_CONSTRAINT); graphicAlgorithmService.setLocation(nameText, DISTANCE_FROM_CONNECTION_LINE, (numberOfReferencedRelations-1)*HEIGHT_CONSTRAINT);
PropertyUtil.setShape_IdValue(constraintName, SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR); PropertyUtil.setShape_IdValue(constraintName, SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR);
link(constraintName, addContext.getNewObject()); link(constraintName, addContext.getNewObject());
return constraintName; return constraintName;
......
...@@ -8,6 +8,7 @@ import org.eclipse.graphiti.mm.pictograms.Connection; ...@@ -8,6 +8,7 @@ import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.util.IColorConstant; import org.eclipse.graphiti.util.IColorConstant;
import org.framed.iorm.model.OrmFactory; import org.framed.iorm.model.OrmFactory;
import org.framed.iorm.model.Relation; import org.framed.iorm.model.Relation;
import org.framed.iorm.model.Shape;
import org.framed.iorm.model.Type; import org.framed.iorm.model.Type;
import org.framed.iorm.ui.literals.IdentifierLiterals; import org.framed.iorm.ui.literals.IdentifierLiterals;
import org.framed.iorm.ui.literals.LayoutLiterals; import org.framed.iorm.ui.literals.LayoutLiterals;
...@@ -135,7 +136,9 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt ...@@ -135,7 +136,9 @@ public abstract class AbstractRoleConstraintPattern extends FRaMEDConnectionPatt
newRoleConstraint.setContainer(sourceShape.getContainer()); newRoleConstraint.setContainer(sourceShape.getContainer());
sourceShape.getContainer().getElements().add(newRoleConstraint); sourceShape.getContainer().getElements().add(newRoleConstraint);
newRoleConstraint.setSource(sourceShape); newRoleConstraint.setSource(sourceShape);
newRoleConstraint.getReferencedRoles().add((Shape) sourceShape);
newRoleConstraint.setTarget(targetShape); newRoleConstraint.setTarget(targetShape);
newRoleConstraint.getReferencedRoles().add((Shape) targetShape);
//Step 4 //Step 4
AddConnectionContext addContext = new AddConnectionContext(sourceAnchor, targetAnchor); AddConnectionContext addContext = new AddConnectionContext(sourceAnchor, targetAnchor);
addContext.setNewObject(newRoleConstraint); addContext.setNewObject(newRoleConstraint);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment