Skip to content
Snippets Groups Projects
Commit d53424fa authored by nullsub's avatar nullsub
Browse files

Merge remote-tracking branch 'origin/develop' into feature-editpolicy

parents a48bffe9 08199b13
No related branches found
No related tags found
No related merge requests found
Showing
with 1759 additions and 388 deletions
......@@ -11,6 +11,6 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.framed.iorm.featuremodel.provider,
org.framed.iorm.model.provider
Require-Bundle: org.eclipse.core.runtime,
org.framed.iorm.model;visibility:=reexport,
org.framed.iorm.model;bundle-version="1.0.0";visibility:=reexport,
org.eclipse.emf.edit;visibility:=reexport
Bundle-ActivationPolicy: lazy
......@@ -7,12 +7,31 @@ Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.framed.iorm.featuremodel,
org.framed.iorm.featuremodel.impl,
org.framed.iorm.featuremodel.util,
Export-Package: org.framed.iorm.featuremodel;uses:="org.eclipse.emf.ecore,org.eclipse.emf.common.util",
org.framed.iorm.featuremodel.impl;
uses:="org.eclipse.emf.ecore,
org.eclipse.emf.ecore.impl,
org.eclipse.emf.common.util,
org.framed.iorm.featuremodel",
org.framed.iorm.featuremodel.util;
uses:="org.eclipse.emf.ecore,
org.framed.iorm.featuremodel,
org.eclipse.emf.common.notify,
org.eclipse.emf.common.notify.impl,
org.eclipse.emf.ecore.util",
org.framed.iorm.model,
org.framed.iorm.model.impl,
org.framed.iorm.model.util
org.framed.iorm.model.impl;
uses:="org.eclipse.emf.ecore,
org.eclipse.emf.ecore.impl,
org.eclipse.emf.common.util,
org.framed.iorm.featuremodel,
org.framed.iorm.model",
org.framed.iorm.model.util;
uses:="org.eclipse.emf.ecore,
org.eclipse.emf.common.notify,
org.eclipse.emf.common.notify.impl,
org.eclipse.emf.ecore.util,
org.framed.iorm.model"
Require-Bundle: org.eclipse.emf.common;bundle-version="2.13.0",
org.eclipse.core.runtime,
org.eclipse.emf.ecore;bundle-version="2.13.0";visibility:=reexport
......
This diff is collapsed.
......@@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.framed.iorm.transformation;bundle-version="1.0.0",
org.junit,
org.rosi.crom.metamodel;visibility:=reexport,
org.framed.iorm.model;bundle-version="0.1.0";visibility:=reexport,
org.framed.iorm.model;bundle-version="1.0.0";visibility:=reexport,
org.eclipse.emf.ecore.xmi,
org.eclipse.compare;bundle-version="3.5.501",
org.eclipse.emf.compare;bundle-version="3.1.0",
......
......@@ -27,10 +27,9 @@ Require-Bundle: org.framed.iorm.featuremodel;bundle-version="1.0.0",
org.eclipse.core.resources;bundle-version="3.11.1";visibility:=reexport,
org.eclipse.ui.workbench,
org.eclipse.emf.ecore,
org.framed.iorm.editpolicymodel;bundle-version="0.1.0"
org.framed.iorm.editpolicymodel;bundle-version="0.1.0",
org.eclipse.osgi
Import-Package: org.eclipse.graphiti.features;version="0.13.2",
org.framed.iorm.model,
org.framed.iorm.model.provider,
org.framed.iorm.transformation
Bundle-ClassPath: src/,
.
......@@ -49,17 +49,15 @@ public class AttributePattern extends AttributeOperationCommonPattern implements
Object businessObject = getBusinessObjectForPictogramElement(pictogramElement);
if(businessObject instanceof org.framed.iorm.model.Shape) {
org.framed.iorm.model.Shape shape = (org.framed.iorm.model.Shape) businessObject;
if(shape.getFirstSegment() != null && shape.getSecondSegment() !=null) {
if(util.usedInModelTypes(usedInReferences).contains(shape.getType())) {
boolean isShadowShape = false;
for(AbstractHasAttsAndOpsReference haaor : usedInReferences) {
if(UIUtil.isShape_IdValue((Shape) pictogramElement, haaor.getShadowShapeID()))
isShadowShape = true;
}
if(!isShadowShape) {
if(!isShadowShape)
return EditPolicyService.getHandler(this.getDiagram()).canCreateAttribute(createContext, shape.getType());
}
} } }
} }
return false;
}
......
package customFeatures;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.pattern.IPattern;
import org.framed.iorm.featuremodel.FRaMEDConfiguration;
import org.framed.iorm.featuremodel.FRaMEDFeature;
import org.framed.iorm.featuremodel.FeatureName;
import org.framed.iorm.featuremodel.FeaturemodelFactory;
import org.framed.iorm.model.Model;
import org.framed.iorm.ui.FRaMEDCustomFeature;
import org.framed.iorm.ui.UIUtil;
......@@ -16,6 +21,7 @@ import de.ovgu.featureide.fm.core.base.IFeature;
import de.ovgu.featureide.fm.core.configuration.Configuration;
import org.framed.iorm.ui.palette.FeaturePaletteDescriptor; //*import for javadoc link
import org.framed.iorm.ui.providers.FeatureProvider;
import org.framed.iorm.ui.configuration.ChangeConfigurationContext; //*import for javadoc link
import org.framed.iorm.ui.editPolicy.EditPolicyService;
import org.framed.iorm.ui.configuration.ChangeConfigurationCommand; //*import for javadoc link
......@@ -36,13 +42,56 @@ public class ChangeConfigurationFeature extends FRaMEDCustomFeature {
*/
Literals literals = new Literals();
/**
* the register for the multipage editors to synchronize
*/
private List<ChangeConfigurationListener> registeredListeners = new ArrayList<ChangeConfigurationListener>();
/**
* Class constructor
* <p>
* It adds any pattern of its feature provider which is also a {@link ChangeConfigurationListener} to its list of
* listeners.
* @param featureProvider the feature provider the feature belongs to
*/
public ChangeConfigurationFeature(IFeatureProvider featureProvider) {
super(featureProvider);
FEATURE_NAME = literals.CHANGE_CONFIGURATION_FEATURE_NAME;
if(featureProvider instanceof FeatureProvider) {
FeatureProvider framedFeatureProvider = (FeatureProvider) featureProvider;
for(IPattern ipattern : framedFeatureProvider.getPatterns()) {
if(ipattern instanceof ChangeConfigurationListener) {
registerListener((ChangeConfigurationListener) ipattern);
} } }
}
/**
* operation to add a pattern to the list of listeners
* @param multipageEditor the multipage editor to add
*/
private void registerListener(ChangeConfigurationListener listener) {
registeredListeners.add(listener);
}
/**
* notify listeners about changes in the configuration by giving the the old and new configuration in the form of a string list
* @param framedFeatureConfiguration the newly changed configuration
* @param oldFramedConfiguration the configuration before the changes
*/
private void notifyListeners(FRaMEDConfiguration framedFeatureConfiguration, FRaMEDConfiguration oldFramedConfiguration) {
List<String> newFramedFeatureNames = new ArrayList<String>();
for(FRaMEDFeature framedFeature : framedFeatureConfiguration.getFeatures()) {
newFramedFeatureNames.add(framedFeature.getName().getLiteral());
}
List<String> oldFramedFeatureNames = new ArrayList<String>();
for(FRaMEDFeature framedFeature : oldFramedConfiguration.getFeatures()) {
oldFramedFeatureNames.add(framedFeature.getName().getLiteral());
}
for(ChangeConfigurationListener listener : registeredListeners) {
listener.configurationChanged(newFramedFeatureNames, oldFramedFeatureNames);
}
}
/**
......@@ -72,31 +121,39 @@ public class ChangeConfigurationFeature extends FRaMEDCustomFeature {
/**
* This method changes the role models configuration using the following steps:
* <p>
* Step 1: It creates a new empty {@link FRaMEDConfiguration}.<br>
* Step 2: For every selected feature in the feature editors configuration add an equivalent
* Step 1: It saves the configuration before the changes done.<br>
* Step 2: It executes the changes.<br>
* Step 3: It creates a new empty {@link FRaMEDConfiguration}.<br>
* Step 4: For every selected feature in the feature editors configuration add an equivalent
* {@link FRaMEDFeature} to the created FRaMEDConfiguration.<br>
* Step 3: Set the created FRaMEDConfiguration as configuration of the edited role model.
* Step 4: Refresh the palette to change the shown palette entries according to their feature expressions.
* See {@link FeaturePaletteDescriptor} for further informations.
* Step 5: Set the created FRaMEDConfiguration as configuration of the edited role model.
* Step 6: Refresh the palette to change the shown palette entries according to their feature expressions.
* See {@link FeaturePaletteDescriptor} for further informations.<br>
* Step 7: It notifies its listeners about the changes in the configuration.
* @throws ConfigurationInconsistentException
*/
@Override
public void execute(ICustomContext context) {
ChangeConfigurationContext cfmc = (ChangeConfigurationContext) context;
//Step 1
Diagram mainDiagram = UIUtil.getMainDiagramForAnyDiagram(getDiagram());
Model mainModel = UIUtil.getLinkedModelForDiagram(mainDiagram);
FRaMEDConfiguration oldFramedConfiguration = mainModel.getFramedConfiguration();
//Step 2
ChangeConfigurationContext cfmc = (ChangeConfigurationContext) context;
//Step 3
FRaMEDConfiguration framedFeatureConfiguration = FeaturemodelFactory.eINSTANCE.createFRaMEDConfiguration();
Configuration editorFeatureConfiguration = cfmc.getConfiguration();
for(IFeature editorFeature : editorFeatureConfiguration.getSelectedFeatures()) {
//Step 2
//Step 4
FRaMEDFeature framedFeature = FeaturemodelFactory.eINSTANCE.createFRaMEDFeature();
framedFeature.setName(FeatureName.getByName(editorFeature.getName()));
framedFeatureConfiguration.getFeatures().add(framedFeature);
}
//Step 3
Diagram mainDiagram = UIUtil.getMainDiagramForAnyDiagram(getDiagram());
UIUtil.getLinkedModelForDiagram(mainDiagram).setFramedConfiguration(framedFeatureConfiguration);
EditPolicyService.setConfiguration(mainDiagram, framedFeatureConfiguration);
//Step 4
//Step 5
mainModel.setFramedConfiguration(framedFeatureConfiguration);
//Step 6
getFeatureProvider().getDiagramTypeProvider().getDiagramBehavior().refreshPalette();
//Step 7
notifyListeners(framedFeatureConfiguration, oldFramedConfiguration);
}
}
package customFeatures;
import java.util.List;
/**
* This interface is meant for graphiti pattern that
*/
public interface ChangeConfigurationListener {
/**
* When the configuration is changed this operation is called on the listener implementing this interface.
* @param newframedFeatureNames the newly changed configuration
* @param oldframedFeatureNames the configuration before the changes
*/
public void configurationChanged(List<String> newframedFeatureNames, List<String> oldframedFeatureNames);
}
......@@ -181,15 +181,13 @@ public class InheritancePattern extends FRaMEDConnectionPattern {
if(source instanceof org.framed.iorm.model.Shape && target instanceof org.framed.iorm.model.Shape) {
org.framed.iorm.model.Shape sourceShape = (org.framed.iorm.model.Shape) source;
org.framed.iorm.model.Shape targetShape = (org.framed.iorm.model.Shape) target;
if(sourceShape.getFirstSegment() != null && sourceShape.getSecondSegment() !=null &&
targetShape.getFirstSegment() != null && targetShape.getSecondSegment() !=null) {
if(sourceShape != null && targetShape != null) {
if(sourceShape.getContainer() == targetShape.getContainer() &&
!(sourceShape.equals(targetShape))) {
if(types.contains(sourceShape.getType()))
if(targetShape.getType() == sourceShape.getType())
return EditPolicyService.getHandler(this.getDiagram()).canCreate(createContext, Type.INHERITANCE);
} } } }
} } }
return false;
}
......
......@@ -4,13 +4,18 @@ import org.eclipse.graphiti.util.IColorConstant;
import org.framed.iorm.ui.UILiterals;
import org.framed.iorm.ui.palette.PaletteView;
/**
* The literals of role models are mostly the same as the ones of a compartment type, since a created role model is handled like
* a compartment type if the corresponding feature is chosen.
* @author Kevin Kassin
*/
public class Literals {
/**
* the features names used for the palette entry of this feature
*/
public final String FEATURE_NAME = "Role Model",
ELEMENTS_FEATURE_NAME = "RoleModelPattern";
ELEMENTS_FEATURE_NAME = "RoleModelElementPattern";
/**
* the standard name for a pictogramm element and business object created by the feature
......@@ -20,9 +25,9 @@ public class Literals {
/**
* the ids or the paths for icon used for palette entry of this feature
*/
public final String ICON_IMG_ID = "org.framed.iorm.ui.modules.roleModel",
ELEMENTS_ICON_IMG_ID = "org.framed.iorm.ui.modules.roleModelElements",
ICON_IMG_PATH = "modules/rolemodel/icon_rolemodel.png";
public final String ICON_IMG_ID = "org.framed.iorm.ui.core.rolemodel",
ELEMENTS_ICON_IMG_ID = "org.framed.iorm.ui.core.roleModelElements",
ICON_IMG_PATH = "core/rolemodel/icon_rolemodel.png";
/**
* the kind of diagram this module's pattern creates
......@@ -35,7 +40,7 @@ public class Literals {
public final PaletteView paletteView = PaletteView.COMPARTMENT_VIEW;
/**
* identifiers used for role models: most are the same as a compartment types identifier
* identifiers used for role models
* <p>
* can be for:<br>
* (1) the container shape or<br>
......@@ -51,23 +56,31 @@ public class Literals {
* (11) the elements in the content preview segment or<br>
* (12) the dot elements that indicate some elements are not shown in the preview
*/
public final String SHAPE_ID_COMPARTMENTTYPE_CONTAINER = "shape_ct_container",
SHAPE_ID_COMPARTMENTTYPE_TYPEBODY = "shape_ct_typebody",
SHAPE_ID_COMPARTMENTTYPE_SHADOW = "shape_ct_shadow",
SHAPE_ID_COMPARTMENTTYPE_NAME = "shape_ct_name",
SHAPE_ID_COMPARTMENTTYPE_FIRSTLINE = "shape_ct_firstline",
SHAPE_ID_COMPARTMENTTYPE_SECONDLINE = "shape_ct_secondline",
SHAPE_ID_COMPARTMENTTYPE_THIRDLINE = "shape_ct_thirdline",
SHAPE_ID_COMPARTMENTTYPE_ATTRIBUTECONTAINER = "shape_ct_attcontainer",
SHAPE_ID_COMPARTMENTTYPE_OPERATIONCONTAINER = "shape_ct_opcontainer",
SHAPE_ID_COMPARTMENTTYPE_CONTENT_PREVIEW = "shape_ct_contentpreview",
SHAPE_ID_ROLEMODEL_ELEMENT = "shape_rm_element",
SHAPE_ID_ROLEMODEL_INDICATOR_DOTS = "shape_rm_indicator_dots";
public final String SHAPE_ID_ROLEMODEL_CONTAINER = "shape_ct_container",
SHAPE_ID_ROLEMODEL_TYPEBODY = "shape_ct_typebody",
SHAPE_ID_ROLEMODEL_SHADOW = "shape_ct_shadow",
SHAPE_ID_ROLEMODEL_NAME = "shape_ct_name",
SHAPE_ID_ROLEMODEL_FIRSTLINE = "shape_ct_firstline",
SHAPE_ID_ROLEMODEL_SECONDLINE = "shape_ct_secondline",
SHAPE_ID_ROLEMODEL_THIRDLINE = "shape_ct_thirdline",
SHAPE_ID_ROLEMODEL_ATTRIBUTECONTAINER = "shape_ct_attcontainer",
SHAPE_ID_ROLEMODEL_OPERATIONCONTAINER = "shape_ct_opcontainer",
SHAPE_ID_ROLEMODEL_CONTENT_PREVIEW = "shape_ct_contentpreview",
SHAPE_ID_ROLEMODEL_ELEMENT = "shape_ct_element",
SHAPE_ID_ROLEMODEL_INDICATOR_DOTS = "shape_ct_indicator_dots";
/**
* messages used as direct editing tips
*/
public final String DIRECTEDITING_ROLEMODEL = "A compartment types name cant be empty or contain spaces. Numbers are allowed but not as first symbol.",
NAME_ALREADY_USED_ROLEMODEL = "Another compartment type already has the same name!";
/**
* reason messages used in the <em>updateNeeded</em> operations of the shape pattern
*/
public final String REASON_AMOUNT_ELEMENTS = "Different amount of elements.",
public final String REASON_NAME_NULL = "Name is null.",
REASON_NAME_OUT_OF_DATE = "Name is out of date.",
REASON_AMOUNT_ELEMENTS = "Different amount of elements.",
REASON_NAMES_ELEMENTS = "Different names of elements.";
/**
......@@ -89,8 +102,8 @@ public class Literals {
* (3) the color of backgrounds or<br>
* (4) the color of graphiti shapes shadows
*/
public final IColorConstant COLOR_TEXT = IColorConstant.GRAY,
COLOR_LINES = IColorConstant.GRAY,
public final IColorConstant COLOR_TEXT = UILiterals.COLOR_TEXT,
COLOR_LINES = UILiterals.COLOR_LINES,
COLOR_BACKGROUND = UILiterals.COLOR_BACKGROUND,
COLOR_SHADOW = IColorConstant.LIGHT_GRAY;
COLOR_SHADOW = UILiterals.COLOR_SHADOW;
}
......@@ -20,9 +20,9 @@ public class RoleModelGroupingFeatureReference extends AbstractGroupingFeatureRe
public RoleModelGroupingFeatureReference() {
modelType = Type.COMPARTMENT_TYPE;
DIAGRAM_KIND = literals.DIAGRAM_KIND;
SHAPE_ID_CONTAINER = literals.SHAPE_ID_COMPARTMENTTYPE_CONTAINER;
SHAPE_ID_NAME = literals.SHAPE_ID_COMPARTMENTTYPE_NAME;
SHAPE_ID_TYPEBODY = literals.SHAPE_ID_COMPARTMENTTYPE_TYPEBODY;
SHAPE_ID_CONTAINER = literals.SHAPE_ID_ROLEMODEL_CONTAINER;
SHAPE_ID_NAME = literals.SHAPE_ID_ROLEMODEL_NAME;
SHAPE_ID_TYPEBODY = literals.SHAPE_ID_ROLEMODEL_TYPEBODY;
paletteView = literals.paletteView;
}
}
......@@ -6,9 +6,11 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.framed.iorm.ui.UIUtil;
import org.framed.iorm.ui.references.AbstractAttributeAndOperationReference;
/**
* This class offers utility operations in the scope of the role model feature module.
* This class offers utility operations in the scope of the role model feature module. This operations are mostly the same as the
* ones of a compartment type, since a created role model is handled like a compartment type if the corresponding feature is chosen.
* @author Kevin Kassin
*/
public class Util {
......@@ -18,6 +20,29 @@ public class Util {
*/
private final Literals literals = new Literals();
/**
* a reference class which encapsulates the dependency to the attribute and operation features
*/
private final AbstractAttributeAndOperationReference aaoReference = UIUtil.getAttributeAndOperationFeatureReference();
/**
* This operation calculates where the horizontal first third of a role model is.
* @param heightOfCompartmentType the height of the role model
* @return the horizontal first third of the role model
*/
public final int calculateHorizontaltFirstThird(int heightOfCompartmentType) {
return ((heightOfCompartmentType-literals.HEIGHT_NAME_SHAPE)/3)+literals.HEIGHT_NAME_SHAPE;
}
/**
* This operation calculates where the horizontal second third of a role model is.
* @param heightOfCompartmentType the height of the role model
* @return the horizontal second third of the role model
*/
public final int calculateHorizontaltSecondThird(int heightOfCompartmentType) {
return 2*calculateHorizontaltFirstThird(heightOfCompartmentType)-literals.HEIGHT_NAME_SHAPE;
}
//Diagram
//~~~~~~~
/**
......@@ -26,7 +51,7 @@ public class Util {
*/
public Diagram getCompartmentTypeDiagramForItsShape(Shape groupOrCompartmentTypeShape, Diagram diagram) {
return UIUtil.getDiagramForGroupingShape(groupOrCompartmentTypeShape, diagram,
literals.SHAPE_ID_COMPARTMENTTYPE_TYPEBODY, literals.SHAPE_ID_COMPARTMENTTYPE_NAME, literals.DIAGRAM_KIND);
literals.SHAPE_ID_ROLEMODEL_TYPEBODY, literals.SHAPE_ID_ROLEMODEL_NAME, literals.DIAGRAM_KIND);
}
//Update
......@@ -35,7 +60,35 @@ public class Util {
* Convenience operation to call {@link UIUtil#getNameOfPictogramElement(PictogramElement, String)} with the correct parameters.
*/
public String getNameOfPictogramElement(PictogramElement pictogramElement) {
return UIUtil.getNameOfPictogramElement(pictogramElement, literals.SHAPE_ID_COMPARTMENTTYPE_NAME);
return UIUtil.getNameOfPictogramElement(pictogramElement, literals.SHAPE_ID_ROLEMODEL_NAME);
}
/**
* Convenience operation to call {@link UIUtil#getpictogramAttributeNames(PictogramElement, String, String)} with the correct parameters.
*/
public List<String> getpictogramAttributeNames(PictogramElement pictogramElement) {
return UIUtil.getpictogramAttributeNames(pictogramElement, literals.SHAPE_ID_ROLEMODEL_ATTRIBUTECONTAINER, aaoReference.SHAPE_ID_ATTRIBUTE_TEXT);
}
/**
* Convenience operation to call {@link UIUtil#getBusinessAttributeNames(PictogramElement, String, String)} with the correct parameters.
*/
public List<String> getBusinessAttributeNames(PictogramElement pictogramElement) {
return UIUtil.getBusinessAttributeNames(pictogramElement, literals.SHAPE_ID_ROLEMODEL_ATTRIBUTECONTAINER, aaoReference.SHAPE_ID_ATTRIBUTE_TEXT);
}
/**
* Convenience operation to call {@link UIUtil#getpictogramOperationNames(PictogramElement, String, String)} with the correct parameters.
*/
public List<String> getpictogramOperationNames(PictogramElement pictogramElement) {
return UIUtil.getpictogramOperationNames(pictogramElement, literals.SHAPE_ID_ROLEMODEL_OPERATIONCONTAINER, aaoReference.SHAPE_ID_OPERATION_TEXT);
}
/**
* Convenience operation to call {@link UIUtil#getBusinessOperationNames(PictogramElement, String, String)} with the correct parameters.
*/
public List<String> getBusinessOperationNames(PictogramElement pictogramElement) {
return UIUtil.getBusinessOperationNames(pictogramElement, literals.SHAPE_ID_ROLEMODEL_OPERATIONCONTAINER, aaoReference.SHAPE_ID_OPERATION_TEXT);
}
/**
......@@ -43,6 +96,6 @@ public class Util {
* with the correct parameters.
*/
public List<String> getContentPreviewElementsNames(PictogramElement pictogramElement) {
return UIUtil.getContentPreviewElementsNames(pictogramElement, literals.SHAPE_ID_COMPARTMENTTYPE_CONTENT_PREVIEW, literals.SHAPE_ID_ROLEMODEL_ELEMENT);
return UIUtil.getContentPreviewElementsNames(pictogramElement, literals.SHAPE_ID_ROLEMODEL_CONTENT_PREVIEW, literals.SHAPE_ID_ROLEMODEL_ELEMENT);
}
}
org.framed.iorm.ui/core/rolemodel/icon_rolemodel.png

288 B

......@@ -12,7 +12,8 @@ public class Literals {
/**
* the features name used for the palette entry of this feature
*/
public final String FEATURE_NAME = "Role Type";
public final String FEATURE_NAME = "Role Type",
OC_FEATURE_NAME = "RT Occurrence Constraints";
/**
* name of the custom feature
......@@ -30,6 +31,7 @@ public class Literals {
* the id or the path for icon used for palette entry of this feature
*/
public final String ICON_IMG_ID = "org.framed.iorm.ui.core.roletype",
OC_ICON_IMG_ID = "org.framed.iorm.ui.modules.rt_oc",
ICON_IMG_PATH = "core/roletype/icon_roletype.png";
/**
......
package roletype;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
......@@ -30,6 +31,8 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.pattern.AbstractPattern;
import org.eclipse.graphiti.pattern.IPattern;
import org.framed.iorm.featuremodel.FRaMEDConfiguration;
import org.framed.iorm.featuremodel.FRaMEDFeature;
import org.framed.iorm.model.Model;
import org.framed.iorm.model.NamedElement;
import org.framed.iorm.model.OrmFactory;
......@@ -245,6 +248,7 @@ public class RoleTypePattern extends FRaMEDShapePattern implements IPattern {
Shape cardinalityShape = pictogramElementCreateService.createShape(containerShape, true);
Text cardinalityText = graphicAlgorithmService.createText(cardinalityShape, addedRoleType.getDescription().getName());
cardinalityText.setForeground(manageColor(literals.COLOR_TEXT));
cardinalityShape.setVisible(occurrenceConstraintChosen());
graphicAlgorithmService.setLocationAndSize(cardinalityText,
x+width/2-literals.HEIGHT_OCCURRENCE_CONSTRAINT/2,
y-literals.HEIGHT_OCCURRENCE_CONSTRAINT-literals.PUFFER_BETWEEN_ELEMENTS,
......@@ -327,6 +331,24 @@ public class RoleTypePattern extends FRaMEDShapePattern implements IPattern {
return containerShape;
}
/**
* calculates if the occurrence constraint feature is chosen when creating a role group
* <p>
* TODO: This should be modularized in a later stage of the development by separating the occurence constraint concern
* from this pattern.
* @return if the occurrence constraint feature is chosen when creating a role group
*/
private boolean occurrenceConstraintChosen() {
Diagram mainDiagram = UIUtil.getMainDiagramForAnyDiagram(getDiagram());
Model mainModel = UIUtil.getLinkedModelForDiagram(mainDiagram);
FRaMEDConfiguration framedConfiguration = mainModel.getFramedConfiguration();
List<String> framedFeatureNames = new ArrayList<String>();
for(FRaMEDFeature framedFeature : framedConfiguration.getFeatures()) {
framedFeatureNames.add(framedFeature.getName().getLiteral());
}
return framedFeatureNames.contains("Occurrence_Constraints");
}
//create feature
//~~~~~~~~~~~~~~
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment