diff --git a/org.framed.iorm.ui/icons/features/icon_fulfillment.png b/org.framed.iorm.ui/icons/features/icon_fulfillment.png new file mode 100644 index 0000000000000000000000000000000000000000..84d6feb801e2e091692fcd41fab93f9a0cb5eb01 Binary files /dev/null and b/org.framed.iorm.ui/icons/features/icon_fulfillment.png differ diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/EditFulfillmentFeature.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/EditFulfillmentFeature.java new file mode 100644 index 0000000000000000000000000000000000000000..2e51e6f3e09213528371186a7061d3329aaa0111 --- /dev/null +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/EditFulfillmentFeature.java @@ -0,0 +1,82 @@ +package org.framed.iorm.ui.graphitifeatures; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.graphiti.features.IFeatureProvider; +import org.eclipse.graphiti.features.context.ICustomContext; +import org.eclipse.graphiti.features.custom.AbstractCustomFeature; +import org.eclipse.graphiti.mm.pictograms.Connection; +import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator; +import org.eclipse.jface.window.Window; +import org.eclipse.ui.PlatformUI; +import org.framed.iorm.model.Relation; +import org.framed.iorm.model.Shape; +import org.framed.iorm.ui.literals.NameLiterals; +import org.framed.iorm.ui.providers.ToolBehaviorProvider; +import org.framed.iorm.ui.wizards.EditFulfillmentDialog; +import org.framed.iorm.ui.wizards.EditRelationshipDialog; + +public class EditFulfillmentFeature extends AbstractCustomFeature { + + /** + * the name of the feature gathered from {@link NameLiterals} + */ + private final String EDIT_FULFILLMENT_FEATURE_NAME = NameLiterals.EDIT_FULFILLMENT_FEATURE_NAME; + + public EditFulfillmentFeature(IFeatureProvider featureProvider) { + super(featureProvider); + } + + /** + * get method for the features name + * @return the name of the feature + */ + @Override + public String getName() { + return EDIT_FULFILLMENT_FEATURE_NAME; + } + + /** + * This methods checks if the feature can be executed. + * <p> + * return simply true since the check if the feature can be called on the given pictogram element + * is done in the {@link ToolBehaviorProvider}. + * @return if the feature can be executed + */ + @Override + public boolean canExecute(ICustomContext customContext) { + return true; + } + + /** + * opens an TODO {@link } to take the user input for the edit of the fulfillment + * and propagates the edits to the pictogram and business model + * <p> + * there hardly no checks for sizes of collections and types when casting since these checks are done + * {@link ToolBehaviorProvider}. + */ + @Override + public void execute(ICustomContext context) { + List<Shape> newReferencedRoles = new ArrayList<Shape>(); + Connection connection = null; + if(context.getPictogramElements()[0] instanceof Connection) { + connection = (Connection) context.getPictogramElements()[0]; + } + if(context.getPictogramElements()[0] instanceof ConnectionDecorator) { + connection = ((ConnectionDecorator) context.getPictogramElements()[0]).getConnection(); + } + if(connection == null) return; + Relation businessObject = (Relation) getBusinessObjectForPictogramElement(connection); + + EditFulfillmentDialog editDialog = new EditFulfillmentDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + getDiagram(), businessObject, newReferencedRoles); + int returnCode = editDialog.open(); + if(returnCode == Window.OK) { + businessObject.getReferencedRoles().clear(); + for(Shape role : newReferencedRoles) + businessObject.getReferencedRoles().add(role); + } + } + +} diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/EditRelationshipFeature.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/EditRelationshipFeature.java index 68dd3d73eac2278cd48cc170c5b47ea566876aa5..f8b89e5dca6561eff5d6a7dd7ed95753e07658c6 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/EditRelationshipFeature.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/graphitifeatures/EditRelationshipFeature.java @@ -29,12 +29,12 @@ public class EditRelationshipFeature extends AbstractCustomFeature { /** * the name of the feature gathered from {@link NameLiterals} */ - private String EDIT_RELATIONSHIP_FEATURE_NAME = NameLiterals.EDIT_RELATIONSHIP_FEATURE_NAME; + private final String EDIT_RELATIONSHIP_FEATURE_NAME = NameLiterals.EDIT_RELATIONSHIP_FEATURE_NAME; /** * values for property shape id of the connection decorators of the relationship */ - private static final String SHAPE_ID_RELATIONSHIP_NAME_DECORATOR = IdentifierLiterals.SHAPE_ID_RELATIONSHIP_NAME_DECORATOR, + private 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; 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 064cb6f903e80649ef1ee79927827dd36f48c851..c790c1ebec9c47a1b71f6b3119e1543321388151 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 @@ -67,7 +67,8 @@ public class IdentifierLiterals { IMG_ID_FEATURE_RELATIONSHIP = IMG_ID_PREFIX + "img_relationship", IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IMG_ID_PREFIX + "img_intrarelationship_constraint", IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION = IMG_ID_PREFIX + "img_relationship_implication", - IMG_ID_FEATURE_RELATIONSHIP_EXCLUSION = IMG_ID_PREFIX + "img_relationship_exclusion"; + IMG_ID_FEATURE_RELATIONSHIP_EXCLUSION = IMG_ID_PREFIX + "img_relationship_exclusion", + IMG_ID_FEATURE_FULFILLMENT = IMG_ID_PREFIX + "img_fulfillment"; /** * feature model identifier @@ -202,6 +203,12 @@ public class IdentifierLiterals { */ public static final String SHAPE_ID_INHERITANCE_DECORATOR = "shape_inheritance_decorator"; + /** + * identifier used for the connection decorators of the fulfillment relation + */ + public static final String SHAPE_ID_FULFILLMENT_ARROWHEAD = "shape_fulfillment_arrowhead", + SHAPE_ID_FULFILLMENT_ROLES = "shape_fulfillment_roles"; + /** * identifiers used for the connection decorators of the name and cardinalities of relationships */ diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/LayoutLiterals.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/LayoutLiterals.java index 9f11155f028692bf86a74999193069392ca11c3c..d21b2b316239bc9a2539999b131d6d2a6c9aed74 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/LayoutLiterals.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/LayoutLiterals.java @@ -49,12 +49,16 @@ public class LayoutLiterals { * <p> * can be:<br> * (1) the length of the textfield in the role model wizard and role model project wizard or<br> - * (2) the height of the dialog to edit connections or<br> - * (3) the width of the dialog to edit connections + * (2) the height of the dialog to edit relationships or<br> + * (3) the width of the dialog to edit relationships or<br> + * (4) the height of the dialog to edit fulfillments or<br> + * (5) the width of the dialog to edit fulfillments */ public static final int LENGHT_TEXTFIELD_WIZARD = 250, - HEIGHT_EDIT_CONNECTION_DIALOG = 185, - WIDTH_EDIT_CONNECTION_DIALOG = 400; + HEIGHT_EDIT_RELATIONSHIP_DIALOG = 185, + WIDTH_EDIT_RELATIONSHIP_DIALOG = 400, + HEIGHT_EDIT_FULFILLMENT_DIALOG = 300, + WIDTH_EDIT_FULFILLMENT_DIALOG = 400; /** * color values for the feature editor 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 edd1760b97c8bf9453d82c1ce2bd2bbf69b24d98..e3455a372b773c7b741bf2461fd217bf7188cd03 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 @@ -110,7 +110,8 @@ public class NameLiterals { * (9) the name of the reflexive constraint create feature or<br> * (10) the name of the total constraint create feature or<br> * (11) the name of the relationship implication create feature or<br> - * (12) the name of the relationship exclusion create feature + * (12) the name of the relationship exclusion create feature or<br> + * (13) the name of the fulfillment create feature */ public static final String INHERITANCE_FEATURE_NAME = "Inheritance", ROLEIMPLICATION_FEATURE_NAME = "Role Implication", @@ -123,7 +124,8 @@ public class NameLiterals { REFLEXIVE_FEATURE_NAME = "Reflexive", TOTAL_FEATURE_NAME = "Total", RELATIONSHIP_IMPLICATION_FEATURE_NAME = "Relationship Implication", - RELATIONSHIP_EXCLUSION_FEATURE_NAME = "Relationship Exclusion"; + RELATIONSHIP_EXCLUSION_FEATURE_NAME = "Relationship Exclusion", + FULFILLMENT_FEATURE_NAME = "Fulfillment"; /** * name literals used in the patterns to be identified by the ToolBehaviorProvider @@ -151,13 +153,15 @@ public class NameLiterals { * can be:<br> * (1) the name of the {@link ChangeConfigurationFeature} or<br> * (2) the name of the {@link EditRelationshipFeature} or<br> - * (3) the name of the {@link StepInFeature} or<br> - * (4) the name of the {@link StepInNewTabeFeature} or<br> - * (5) the name of the {@link StepOutFeature} or<br> - * (6) the name of the {@link ResetLayoutForElementFeature} + * (3) the name of the {@link EditFulfillmentFeature} or<br> + * (4) the name of the {@link StepInFeature} or<br> + * (5) the name of the {@link StepInNewTabeFeature} or<br> + * (6) the name of the {@link StepOutFeature} or<br> + * (7) the name of the {@link ResetLayoutForElementFeature} */ public static final String CHANGE_CONFIGURATION_FEATURE_NAME = "Change Feature Model", EDIT_RELATIONSHIP_FEATURE_NAME = "Edit Relationship", + EDIT_FULFILLMENT_FEATURE_NAME = "Edit Fulfillment", STEP_IN_FEATURE_NAME = "Step In", STEP_IN_NEW_TAB_FEATURE_NAME = "Step In New Tab", STEP_OUT_FEATURE_NAME = "Step out", 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 c297050736852611a295527e5ae4ddd38ace6b22..63b88bb9a5000daf14f6aa2b2d77c3716dca1669 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 @@ -54,14 +54,6 @@ public class URLLiterals { /** * file paths to icons used for connection create features - * <p> - * can be:<br> - * (1) the file path to the icon for the inheritance create feature or<br> - * (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 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", @@ -70,5 +62,6 @@ public class URLLiterals { IMG_FILEPATH_FEATURE_RELATIONSHIP = IMG_FILE_PATH_PREFIX + "relationship.png", IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IMG_FILE_PATH_PREFIX + "intrarelationship_constraint.png", IMG_FILEPATH_FEATURE_RELATIONSHIP_IMPLICATION = IMG_FILE_PATH_PREFIX + "relationship_implication.png", - IMG_FILEPATH_FEATURE_RELATIONSHIP_EXCLUSION = IMG_FILE_PATH_PREFIX + "relationship_exclusion.png"; + IMG_FILEPATH_FEATURE_RELATIONSHIP_EXCLUSION = IMG_FILE_PATH_PREFIX + "relationship_exclusion.png", + IMG_FILEPATH_FEATURE_FULFILLMENT = IMG_FILE_PATH_PREFIX + "fulfillment.png"; } \ No newline at end of file diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeatureManager.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeatureManager.java index de08e5c2ecfde4cb81115234ce3f1f3158b9d0bd..1b817d6c3286795ea6b1bc6fd6da00c49499275c 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeatureManager.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeatureManager.java @@ -40,7 +40,8 @@ public class FeatureManager { REFLEXIVE_FEATURE_NAME = NameLiterals.REFLEXIVE_FEATURE_NAME, TOTAL_FEATURE_NAME = NameLiterals.TOTAL_FEATURE_NAME, RELATIONSHIP_IMPLICATION_FEATURE_NAME = NameLiterals.RELATIONSHIP_IMPLICATION_FEATURE_NAME, - RELATIONSHIP_EXCLUSION_FEATURE_NAME = NameLiterals.RELATIONSHIP_EXCLUSION_FEATURE_NAME; + RELATIONSHIP_EXCLUSION_FEATURE_NAME = NameLiterals.RELATIONSHIP_EXCLUSION_FEATURE_NAME, + FULFILLMENT_FEATURE_NAME = NameLiterals.FULFILLMENT_FEATURE_NAME; /** * simple short forms of the palette categories to make code more readable @@ -92,6 +93,7 @@ public class FeatureManager { //Step 4 features.put(INHERITANCE_FEATURE_NAME, new FeaturePaletteDescriptor(relations, all)); features.put(RELATIONSHIP_FEATURE_NAME, new FeaturePaletteDescriptor(relations, compartment)); + features.put(FULFILLMENT_FEATURE_NAME, new FeaturePaletteDescriptor(relations, all)); //Step 5 features.put(ROLEIMPLICATION_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment)); features.put(ROLEEQUIVALENCE_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment)); diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/FulfillmentPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/FulfillmentPattern.java new file mode 100644 index 0000000000000000000000000000000000000000..3e376e4dd3be3e70bded56f1e80d00c134d35a29 --- /dev/null +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/FulfillmentPattern.java @@ -0,0 +1,251 @@ +package org.framed.iorm.ui.pattern.connections; + +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.features.context.impl.CustomContext; +import org.eclipse.graphiti.features.custom.ICustomFeature; +import org.eclipse.graphiti.mm.algorithms.Polygon; +import org.eclipse.graphiti.mm.algorithms.Polyline; +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.PictogramElement; +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.graphitifeatures.EditFulfillmentFeature; +import org.framed.iorm.ui.graphitifeatures.EditRelationshipFeature; +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.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. + * <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> + * @author Kevin Kassin + */ +public class FulfillmentPattern extends FRaMEDConnectionPattern { + + /** + * the name of the feature gathered from {@link NameLiterals} + */ + private static final String FULFILLMENT_FEATURE_NAME = NameLiterals.FULFILLMENT_FEATURE_NAME; + + /** + * the name of the edit relationship feature gathered from {@link NameLiterals} + */ + 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} + */ + 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 inheritance + */ + private static final String SHAPE_ID_FULFILLMENT_ARROWHEAD = IdentifierLiterals.SHAPE_ID_FULFILLMENT_ARROWHEAD, + SHAPE_ID_FULFILLMENT_ROLES = IdentifierLiterals.SHAPE_ID_FULFILLMENT_ROLES; + + /** + * layout integers gathered from {@link LayoutLiterals} + */ + private static final int DISTANCE_FROM_CONNECTION_LINE = LayoutLiterals.DISTANCE_FROM_CONNECTION_LINE, + FULFILLMENT_ARROWHEAD_LENGTH = LayoutLiterals.ARROWHEAD_LENGTH, + FULFILLMENT_ARROWHEAD_HEIGHT = LayoutLiterals.ARROWHEAD_HEIGHT; + + /** + * the color values gathered from {@link LayoutLiterals} + */ + private static final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS, + COLOR_TEXT = LayoutLiterals.COLOR_TEXT; + + /** + * Class constructor + */ + public FulfillmentPattern() { + super(); + } + + /** + * get method for the features name + * @return the name of the feature + */ + @Override + public String getCreateName() { + return FULFILLMENT_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_FULFILLMENT; + } + + //add feature + //~~~~~~~~~~~ + /** + * 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 + public boolean canAdd(IAddContext addContext) { + if(addContext.getNewObject() instanceof Relation) { + Relation relation = (Relation) addContext.getNewObject(); + if(relation.getType() == Type.FULFILLMENT) + return true; + } + return false; + } + + /** + * 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 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 + */ + @Override + public PictogramElement add(IAddContext addContext) { + IAddConnectionContext addConnectionContext = (IAddConnectionContext) addContext; + Relation addedFulfillment = (Relation) addContext.getNewObject(); + Anchor sourceAnchor = addConnectionContext.getSourceAnchor(); + Anchor targetAnchor = addConnectionContext.getTargetAnchor(); + //Step 1 + Connection connection = pictogramElementCreateService.createFreeFormConnection(getDiagram()); + connection.setStart(sourceAnchor); + connection.setEnd(targetAnchor); + Polyline polyline = graphicAlgorithmService.createPolyline(connection); + polyline.setForeground(manageColor(COLOR_CONNECTIONS)); + polyline.setLineWidth(2); + //Step2 + 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 + Polygon arrowhead = graphicAlgorithmService.createPolygon(arrowheadShape, points); + arrowhead.setForeground(manageColor(COLOR_CONNECTIONS)); + arrowhead.setBackground(manageColor(COLOR_CONNECTIONS)); + PropertyUtil.setShape_IdValue(arrowheadShape, SHAPE_ID_FULFILLMENT_ARROWHEAD); + //Step 3 + ConnectionDecorator rolesShape = pictogramElementCreateService.createConnectionDecorator(connection, true, 0.9, true); + Text roles = graphicAlgorithmService.createText(rolesShape, "TEST"); + graphicAlgorithmService.setLocation(roles, DISTANCE_FROM_CONNECTION_LINE, -1*DISTANCE_FROM_CONNECTION_LINE); + roles.setForeground(manageColor(COLOR_TEXT)); + PropertyUtil.setShape_IdValue(rolesShape, SHAPE_ID_FULFILLMENT_ROLES); + //Step 4 + link(connection, addedFulfillment); + link(arrowheadShape, addedFulfillment); + link(rolesShape, addedFulfillment); + //Step 5 + CustomContext customContext = new CustomContext(); + PictogramElement[] pictogramElement = new PictogramElement[1]; + pictogramElement[0] = connection; + customContext.setPictogramElements(pictogramElement); + ICustomFeature[] customFeatures = getFeatureProvider().getCustomFeatures(customContext); + EditFulfillmentFeature editFulfillmentFeature = + (EditFulfillmentFeature) GeneralUtil.findFeatureByName(customFeatures, EDIT_FULFILLMENT_FEATURE_NAME); + if(editFulfillmentFeature.canExecute(customContext)) + editFulfillmentFeature.execute(customContext); + return connection; + } + + //create feature + //~~~~~~~~~~~~~~ + /** + * calculates if a fulfillment can be created + * <p> + * returns true if<br> + * (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 + public boolean canCreate(ICreateConnectionContext createContext) { + Anchor sourceAnchor = createContext.getSourceAnchor(); + Anchor targetAnchor = createContext.getTargetAnchor(); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + 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(targetShape.getType() == Type.COMPARTMENT_TYPE) + return true; + } } + return false; + } + + /** + * checks if a fulfillment 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 + * @return if fulfillment can be started + */ + @Override + public boolean canStartConnection(ICreateConnectionContext createContext) { + 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) + return true; + } + return false; + } + + /** + * creates the business object of a fulfillment using the following steps: + * <p> + * Step 1: get source and target shapes<br> + * Step 2: get new inheritance and add it to the resource of the diagram<br> + * Step 3: set source, target, referenced roles and container of the fulfillment<br> + * Step 4: call add operation of this pattern + */ + @Override + public Connection create(ICreateConnectionContext createContext) { + //Step 1 + Anchor sourceAnchor = createContext.getSourceAnchor(); + Anchor targetAnchor = createContext.getTargetAnchor(); + org.framed.iorm.model.ModelElement sourceShape = ConnectionPatternUtil.getModelElementForAnchor(sourceAnchor); + org.framed.iorm.model.ModelElement targetShape = ConnectionPatternUtil.getModelElementForAnchor(targetAnchor); + //Step 2 + Relation newFulfillment = OrmFactory.eINSTANCE.createRelation(); + newFulfillment.setType(Type.FULFILLMENT); + if(newFulfillment.eResource() != null) getDiagram().eResource().getContents().add(newFulfillment); + //Step 3 + newFulfillment.setContainer(sourceShape.getContainer()); + sourceShape.getContainer().getElements().add(newFulfillment); + newFulfillment.setSource(sourceShape); + newFulfillment.setTarget(targetShape); + //Step 4 + AddConnectionContext addContext = new AddConnectionContext(sourceAnchor, targetAnchor); + addContext.setNewObject(newFulfillment); + 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/InheritancePattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/InheritancePattern.java index eec0acef2d9265ef49c5df35ea13ba1ddaba6b55..2e091219a879b3f2561bb62fb049b8624ce917b2 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 @@ -42,7 +42,7 @@ public class InheritancePattern extends FRaMEDConnectionPattern { private static final String IMG_ID_FEATURE_INHERITANCE = IdentifierLiterals.IMG_ID_FEATURE_INHERITANCE; /** - * the value for the property shape id for the connection decorator of the inheritance + * the value for the property shape id for the connection decorator of the inheritance */ private static final String SHAPE_ID_INHERITANCE_DECORATOR = IdentifierLiterals.SHAPE_ID_INHERITANCE_DECORATOR; diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/RelationshipPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/RelationshipPattern.java index 765d86afbaaf91bfc9a073ff46853f5fe1da20c3..06044ffc3bf097ad2bc30fea753accb5d5506f3f 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/RelationshipPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/RelationshipPattern.java @@ -23,6 +23,7 @@ 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.GeneralUtil; import org.framed.iorm.ui.util.NameUtil; import org.framed.iorm.ui.util.PropertyUtil; @@ -46,31 +47,31 @@ public class RelationshipPattern extends FRaMEDConnectionPattern { /** * the standard value of cardinalities gathered from {@link NameLiterals} */ - private static final String STANDARD_CARDINALITY = NameLiterals.STANDARD_CARDINALITY; + private final String STANDARD_CARDINALITY = NameLiterals.STANDARD_CARDINALITY; /** * the name of the edit relationship feature gathered from {@link NameLiterals} */ - private String EDIT_RELATIONSHIP_FEATURE_NAME = NameLiterals.EDIT_RELATIONSHIP_FEATURE_NAME; + private final String EDIT_RELATIONSHIP_FEATURE_NAME = NameLiterals.EDIT_RELATIONSHIP_FEATURE_NAME; /** * the identifier for the icon of the create feature gathered from {@link IdentifierLiterals} */ - private static final String IMG_ID_FEATURE_RELATIONSHIP = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP; + private final String IMG_ID_FEATURE_RELATIONSHIP = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP; /** * values for property shape id of the connection decorators of the relationship */ - 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_ANCHOR_DECORATOR = IdentifierLiterals.SHAPE_ID_RELATIONSHIP_ANCHOR_DECORATOR; + private 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_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} */ - private static final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS, - COLOR_TEXT = LayoutLiterals.COLOR_TEXT; + private final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS, + COLOR_TEXT = LayoutLiterals.COLOR_TEXT; /** * layout integers gathered from {@link LayoutLiterals} @@ -192,20 +193,14 @@ public class RelationshipPattern extends FRaMEDConnectionPattern { PictogramElement[] pictogramElement = new PictogramElement[1]; pictogramElement[0] = connection; customContext.setPictogramElements(pictogramElement); - EditRelationshipFeature editRelationshipFeature = getEditRelationshipFeature(customContext); + ICustomFeature[] customFeatures = getFeatureProvider().getCustomFeatures(customContext); + EditRelationshipFeature editRelationshipFeature = + (EditRelationshipFeature) GeneralUtil.findFeatureByName(customFeatures, EDIT_RELATIONSHIP_FEATURE_NAME); if(editRelationshipFeature.canExecute(customContext)) editRelationshipFeature.execute(customContext); return connection; } - private EditRelationshipFeature getEditRelationshipFeature(CustomContext customContext) { - for(ICustomFeature customFeature : getFeatureProvider().getCustomFeatures(customContext)) { - if(customFeature.getName().equals(EDIT_RELATIONSHIP_FEATURE_NAME)) - return (EditRelationshipFeature) customFeature; - } - return null; - } - //create feature //~~~~~~~~~~~~~~ /** 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 a013b49952c227dffe9e6340a9b3f6ba1a1ea3c1..c26e021f7b053e8c4ae4325deb1c018641d0abe1 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 @@ -60,6 +60,7 @@ public class FeatureProvider extends DefaultFeatureProviderWithPatterns { addPattern(new TotalConstraintPattern()); addConnectionPattern(new RelationshipImplicationConstraintPattern()); addConnectionPattern(new RelationshipExclusionConstraintPattern()); + addConnectionPattern(new FulfillmentPattern()); } /** @@ -69,6 +70,7 @@ public class FeatureProvider extends DefaultFeatureProviderWithPatterns { public ICustomFeature[] getCustomFeatures(ICustomContext context) { return new ICustomFeature[] { new ChangeConfigurationFeature(this), new EditRelationshipFeature(this), + new EditFulfillmentFeature(this), new StepInFeature(this), new StepInNewTabFeature(this), new StepOutFeature(this), 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 5504a1bc73b3346c1abf26357418709cdafbd3a1..6ba797b12431c60aa7cb286b4cc721291a4123b7 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 @@ -38,7 +38,8 @@ public class ImageProvider extends AbstractImageProvider { IMG_ID_FEATURE_RELATIONSHIP = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP, IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT = IdentifierLiterals.IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT, IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION, - IMG_ID_FEATURE_RELATIONSHIP_PROHIBITION = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP_EXCLUSION; + IMG_ID_FEATURE_RELATIONSHIP_PROHIBITION = IdentifierLiterals.IMG_ID_FEATURE_RELATIONSHIP_EXCLUSION, + IMG_ID_FEATURE_FULFILLMENT = IdentifierLiterals.IMG_ID_FEATURE_FULFILLMENT; /** * the image file paths to icons used for shape create features gathered from {@link URLLiterals} @@ -65,7 +66,8 @@ public class ImageProvider extends AbstractImageProvider { IMG_FILEPATH_FEATURE_RELATIONSHIP = URLLiterals.IMG_FILEPATH_FEATURE_RELATIONSHIP, IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT = URLLiterals.IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT, IMG_FILEPATH_FEATURE_RELATIONSHIP_IMPLICATION = URLLiterals.IMG_FILEPATH_FEATURE_RELATIONSHIP_IMPLICATION, - IMG_FILEPATH_FEATURE_RELATIONSHIP_PROHIBTION = URLLiterals.IMG_FILEPATH_FEATURE_RELATIONSHIP_EXCLUSION; + IMG_FILEPATH_FEATURE_RELATIONSHIP_PROHIBTION = URLLiterals.IMG_FILEPATH_FEATURE_RELATIONSHIP_EXCLUSION, + IMG_FILEPATH_FEATURE_FULFILLMENT = URLLiterals.IMG_FILEPATH_FEATURE_FULFILLMENT; /** * links the file paths to image identifiers @@ -91,5 +93,6 @@ public class ImageProvider extends AbstractImageProvider { addImageFilePath(IMG_ID_FEATURE_INTRARELATIONSHIP_CONSTRAINT, IMG_FILEPATH_FEATURE_INTRARELATIONSHIP_CONSTRAINT); addImageFilePath(IMG_ID_FEATURE_RELATIONSHIP_IMPLICATION, IMG_FILEPATH_FEATURE_RELATIONSHIP_IMPLICATION); addImageFilePath(IMG_ID_FEATURE_RELATIONSHIP_PROHIBITION, IMG_FILEPATH_FEATURE_RELATIONSHIP_PROHIBTION); + addImageFilePath(IMG_ID_FEATURE_FULFILLMENT, IMG_FILEPATH_FEATURE_FULFILLMENT); } } 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 6f1404137e82d171527fa3c07a48aa9ed796f8c3..5d270c649a8c46d609e6f6ff85c67851a11441ed 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 @@ -68,6 +68,7 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ */ private final String CHANGE_CONFIGURATION_FEATURE_NAME = NameLiterals.CHANGE_CONFIGURATION_FEATURE_NAME, EDIT_RELATIONSHIP_FEATURE_NAME = NameLiterals.EDIT_RELATIONSHIP_FEATURE_NAME, + EDIT_FULFILLMENT_FEATURE_NAME = NameLiterals.EDIT_FULFILLMENT_FEATURE_NAME, STEP_IN_FEATURE_NAME = NameLiterals.STEP_IN_FEATURE_NAME, STEP_IN_NEW_TAB_FEATURE_NAME = NameLiterals.STEP_IN_NEW_TAB_FEATURE_NAME, STEP_OUT_FEATURE_NAME = NameLiterals.STEP_OUT_FEATURE_NAME, @@ -143,13 +144,15 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ * Step 3: If its the {@link ChangeConfigurationFeature}, never add it to this list.<br> * Step 4: If its the {@link EditRelationshipFeature}, only add it to the list if a connection or decorator of * a relationship is right clicked.<br> - * Step 5: If its the {@link StepInFeature} or the {@link StepInNewTabFeature} feature, check if the right clicked + * Step 5: If its the {@link EditFulfillmentFeature}, only add it to the list if a connection or decorator of a + * fulfillment is right clicked.<br> + * Step 6: If its the {@link StepInFeature} or the {@link StepInNewTabFeature} feature, check if the right clicked * pictogram element has a graphics algorithm that is the type body of a group or compartment type. If yes, * add the corresponding context menu entry to the context menu.<br> - * Step 6: If its the {@link StepOutFeature} feature check, show the feature for a diagram only if its one of a group or compartment type. + * Step 7: If its the {@link StepOutFeature} feature check, show the feature for a diagram only if its one of a group or compartment type. * If a shape is right clicked, get the diagram that contains the shape first and then check for the same criteria * for this diagram.<br> - * Step 7: If its the {@link ResetLayoutForElementFeature} add it to the context menu if a relationships connection or + * Step 8: If its the {@link ResetLayoutForElementFeature} add it to the context menu if a relationships connection or * connection decorator is right clicked. Also add it if a role types body shape or occurence constraint is selected. */ @Override @@ -176,7 +179,16 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ if(relation.getType() == Type.RELATIONSHIP) contextMenuEntries.add(superContextEntries[i]); } } break; - //Step 5 + //Step 5 + case EDIT_FULFILLMENT_FEATURE_NAME: + if(pictogramElement instanceof FreeFormConnection || + pictogramElement instanceof ConnectionDecorator) { + if(businessObject instanceof Relation) { + Relation relation = (Relation) businessObject; + if(relation.getType() == Type.FULFILLMENT) + contextMenuEntries.add(superContextEntries[i]); + } } break; + //Step 6 case STEP_IN_FEATURE_NAME : case STEP_IN_NEW_TAB_FEATURE_NAME: if(pictogramElement instanceof Shape && @@ -185,7 +197,7 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ PropertyUtil.isShape_IdValue((Shape) pictogramElement, SHAPE_ID_COMPARTMENTTYPE_TYPEBODY)) contextMenuEntries.add(superContextEntries[i]); } break; - //Step 6 + //Step 7 case STEP_OUT_FEATURE_NAME: if(pictogramElement instanceof Diagram) { Diagram diagram = (Diagram) pictogramElement; @@ -200,7 +212,7 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ PropertyUtil.isDiagram_KindValue(diagram, DIAGRAM_KIND_COMPARTMENT_DIAGRAM)) contextMenuEntries.add(superContextEntries[i]); } } } break; - //Step 7 + //Step 8 case RESET_LAYOUT_FEATURE_NAME: if(pictogramElement instanceof FreeFormConnection || pictogramElement instanceof ConnectionDecorator) { diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/wizards/EditFulfillmentDialog.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/wizards/EditFulfillmentDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..8a0c08f1a3dbc32e3c59a6c41180d0230f1b59bc --- /dev/null +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/wizards/EditFulfillmentDialog.java @@ -0,0 +1,184 @@ +package org.framed.iorm.ui.wizards; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.edit.provider.ItemProvider; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.graphiti.mm.pictograms.Diagram; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.framed.iorm.model.ModelElement; +import org.framed.iorm.model.Relation; +import org.framed.iorm.model.Shape; +import org.framed.iorm.model.Type; +import org.framed.iorm.model.provider.OrmItemProviderAdapterFactory; +import org.framed.iorm.ui.literals.LayoutLiterals; +import org.framed.iorm.ui.literals.NameLiterals; +import org.framed.iorm.ui.literals.TextLiterals; +import org.framed.iorm.ui.util.NameUtil; +import org.framed.iorm.ui.graphitifeatures.EditFulfillmentFeature; //*import for javadox link + +/** + * This class represents a dialog to edit relationships name and cardinalities. + * @author Kevin Kassin + */ +public class EditFulfillmentDialog extends Dialog { + + /** + * the name of the custom feature using this dialog gathered from {@link NameLiterals} + */ + private final String EDIT_FULFILLMENT_FEATURE_NAME = NameLiterals.EDIT_FULFILLMENT_FEATURE_NAME; + + /** + * messages and titles used as tips when invalid inputs happen gathered from {@link TextLiterals} + */ + //TODO + + /** + * the height and width of the dialog gathered from {@link LayoutLiterals} + */ + private final int HEIGHT_EDIT_CONNECTION_DIALOG = LayoutLiterals.HEIGHT_EDIT_FULFILLMENT_DIALOG, + WIDTH_EDIT_CONNECTION_DIALOG = LayoutLiterals.WIDTH_EDIT_FULFILLMENT_DIALOG; + + /** + * the business object of the edited relationship + */ + private Relation businessObject; + + /** + * a reference to a list filled with the referenced roles of the fulfillment commonly used by this dialog and + * the {@link EditFulfillmentFeature} + */ + private List<Shape> newReferencedRoles; + + /** + * The viewer for listing the RoleTypes and the RoleGroups. + * + */ + private CheckboxTableViewer checkboxViewer; + + /** + * Class constructor + * @param parentShell the used shell + * @param businessObject the fulfillment to edit + * @param the commonly used list of the referenced roles of the fulfillment + */ + public EditFulfillmentDialog(Shell parentShell, Diagram diagram, Relation businessObject, List<org.framed.iorm.model.Shape> newReferencedRoles) { + super(parentShell); + this.businessObject = businessObject; + this.newReferencedRoles = newReferencedRoles; + } + + /** + * sets the name and the size of the dialog + */ + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(EDIT_FULFILLMENT_FEATURE_NAME + " " + businessObject.getName()); + newShell.setSize(WIDTH_EDIT_CONNECTION_DIALOG, HEIGHT_EDIT_CONNECTION_DIALOG); + } + + //TODO + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + + List<Shape> allRoles = getAllRolesofTarget(); + EList<Shape> fulfilledRoles = businessObject.getReferencedRoles(); + + //create checkbox + checkboxViewer = CheckboxTableViewer.newCheckList(composite, SWT.CHECK); + checkboxViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + AdapterFactoryLabelProvider labelProvider = + new AdapterFactoryLabelProvider(new OrmItemProviderAdapterFactory()); + AdapterFactoryContentProvider contentProvider = + new AdapterFactoryContentProvider(new OrmItemProviderAdapterFactory()); + checkboxViewer.setLabelProvider(labelProvider); + checkboxViewer.setContentProvider(contentProvider); + checkboxViewer.setInput(new ItemProvider(new OrmItemProviderAdapterFactory(), allRoles)); + // check all the role types and the role groups, which already fulfilled thorugh the fulfillment + for (Shape role : allRoles) { + if (fulfilledRoles.contains(role)) { + checkboxViewer.setChecked(role, true); + } } + addSelectionButtons(composite); + return composite; + } + + //TODO + private List<Shape> getAllRolesofTarget() { + List<Shape> allRoles = new ArrayList<Shape>(); + EList<ModelElement> elementsOfTarget = + ((Shape) businessObject.getTarget()).getModel().getElements(); + for(ModelElement element : elementsOfTarget) { + if(element instanceof Shape && + ((Shape) element).getType() == Type.ROLE_TYPE) + allRoles.add((Shape) element); + } + return allRoles; + } + + //TODO + private void addSelectionButtons(Composite composite) { + + initializeDialogUnits(composite); + + Composite buttonComposite = new Composite(composite, SWT.NONE); + + // setup the button layout + GridLayout layout = new GridLayout(); + layout.numColumns = 0; + layout.marginWidth = 0; + layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); + buttonComposite.setLayout(layout); + buttonComposite.setLayoutData(new GridData(SWT.END, SWT.TOP, true, false)); + + Button selectButton = + createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, "Select All", false); + + // set the functionallity of the select all button + selectButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + checkboxViewer.setAllChecked(true); + } + }); + + Button deselectButton = + createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, "Deselect All", false); + + // set the functionallity of the deselect all button + deselectButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + checkboxViewer.setAllChecked(false); + } + }); + } + + + //TODO + @Override + protected void okPressed() { + for (Object object : checkboxViewer.getCheckedElements()) + newReferencedRoles.add((Shape) object); + close(); + } +} diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/wizards/EditRelationshipDialog.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/wizards/EditRelationshipDialog.java index c65269e5a1064386b201b06bfb3ae91c6b697458..630df4d3896b024892101dfd598eac0a494cc271 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/wizards/EditRelationshipDialog.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/wizards/EditRelationshipDialog.java @@ -47,8 +47,8 @@ public class EditRelationshipDialog extends Dialog { /** * the height and width of the dialog gathered from {@link LayoutLiterals} */ - private final int HEIGHT_EDIT_CONNECTION_DIALOG = LayoutLiterals.HEIGHT_EDIT_CONNECTION_DIALOG, - WIDTH_EDIT_CONNECTION_DIALOG = LayoutLiterals.WIDTH_EDIT_CONNECTION_DIALOG; + private final int HEIGHT_EDIT_RELATIONSHIP_DIALOG = LayoutLiterals.HEIGHT_EDIT_RELATIONSHIP_DIALOG, + WIDTH_EDIT_RELATIONSHIP_DIALOG = LayoutLiterals.WIDTH_EDIT_RELATIONSHIP_DIALOG; /** * the diagram of the compartment type the relation is created in @@ -104,7 +104,7 @@ public class EditRelationshipDialog extends Dialog { protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(EDIT_RELATIONSHIP_FEATURE_NAME + " " + businessObject.getName()); - newShell.setSize(WIDTH_EDIT_CONNECTION_DIALOG, HEIGHT_EDIT_CONNECTION_DIALOG); + newShell.setSize(HEIGHT_EDIT_RELATIONSHIP_DIALOG, WIDTH_EDIT_RELATIONSHIP_DIALOG); } /**