diff --git a/org.framed.iorm.featuremodel/model.xml b/org.framed.iorm.featuremodel/model.xml index ab690271aa1bf2525b8190586eb87b4d43113e68..1f12cb46209d2878b837188e43924de1de007d74 100644 --- a/org.framed.iorm.featuremodel/model.xml +++ b/org.framed.iorm.featuremodel/model.xml @@ -1,15 +1,13 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> - <featureModel chosenLayoutAlgorithm="4"> + <featureModel> + <properties/> <struct> <and abstract="true" mandatory="true" name="RML_Feature_Model"> <and abstract="true" mandatory="true" name="Role_Types"> - <description> - - </description> <or abstract="true" name="Role_Structure"> - <feature mandatory="true" name="Role_Properties"/> - <feature mandatory="true" name="Role_Behavior"/> - <feature mandatory="true" name="Role_Inheritance"/> + <feature name="Role_Properties"/> + <feature name="Role_Behavior"/> + <feature name="Role_Inheritance"/> </or> <and abstract="true" mandatory="true" name="Playable"> <and abstract="true" mandatory="true" name="Players"> @@ -20,31 +18,31 @@ </and> </and> <or abstract="true" name="Dependent"> - <feature mandatory="true" name="On_Compartments"/> - <feature mandatory="true" name="On_Relationships"/> + <feature name="On_Compartments"/> + <feature name="On_Relationships"/> </or> <or abstract="true" name="Role_Constraints"> - <feature mandatory="true" name="Role_Implication"/> - <feature mandatory="true" name="Role_Prohibition"/> - <feature mandatory="true" name="Role_Equivalence"/> - <feature mandatory="true" name="Group_Constraints"/> - <feature mandatory="true" name="Occurrence_Constraints"/> + <feature name="Role_Implication"/> + <feature name="Role_Prohibition"/> + <feature name="Role_Equivalence"/> + <feature name="Group_Constraints"/> + <feature name="Occurrence_Constraints"/> </or> </and> <and name="Relationships"> <or abstract="true" name="Relationship_Constraints"> - <feature mandatory="true" name="Relationship_Cardinality"/> - <and mandatory="true" name="Intra_Relationship_Constraints"> + <feature name="Relationship_Cardinality"/> + <and name="Intra_Relationship_Constraints"> <feature name="Parthood_Constraints"/> </and> - <feature mandatory="true" name="Inter_Relationship_Constraints"/> + <feature name="Inter_Relationship_Constraints"/> </or> </and> <and name="Compartment_Types"> <or abstract="true" name="Compartment_Structure"> - <feature mandatory="true" name="Compartment_Properties"/> - <feature mandatory="true" name="Compartment_Behavior"/> - <feature mandatory="true" name="Compartment_Inheritance"/> + <feature name="Compartment_Properties"/> + <feature name="Compartment_Behavior"/> + <feature name="Compartment_Inheritance"/> </or> <and abstract="true" mandatory="true" name="Participants"> <feature name="Contains_Compartments"/> @@ -105,6 +103,12 @@ <var>Roles</var> </eq> </rule> + <rule> + <imp> + <var>Playable_by_Defining_Compartment</var> + <var>Compartments</var> + </imp> + </rule> </constraints> <calculations Auto="true" Constraints="true" Features="true" Redundant="true" Tautology="true"/> <comments/> diff --git a/org.framed.iorm.transformation/src/org/framed/iorm/transformation/TransformationExecutor.java b/org.framed.iorm.transformation/src/org/framed/iorm/transformation/TransformationExecutor.java index b10e491bf858cacb45b2ff75714507fa46442425..7dd16dd3f41f85c647fa13f9b985e88843efb1e6 100644 --- a/org.framed.iorm.transformation/src/org/framed/iorm/transformation/TransformationExecutor.java +++ b/org.framed.iorm.transformation/src/org/framed/iorm/transformation/TransformationExecutor.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; +import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.FileAlreadyExistsException; @@ -83,7 +84,7 @@ public class TransformationExecutor extends EpsilonStandalone { URL epsilonFolderURL = TransformationBundle.getEntry("epsilon"); File epsilonFolder = null; try { - epsilonFolder = new File(FileLocator.resolve(epsilonFolderURL).toURI()); + epsilonFolder = new File(resolveURL(FileLocator.resolve(epsilonFolderURL))); } catch (URISyntaxException | IOException e1) { e1.printStackTrace(); }; if(epsilonFolder == null) { System.err.println("No folder 'epsilon' found"); @@ -104,7 +105,7 @@ public class TransformationExecutor extends EpsilonStandalone { !packageETLFilesMarkedAsNotUsed(url.toString(), "modules/")) { //(a) try { - etlFile = new File(FileLocator.resolve(url).toURI()); + etlFile = new File(resolveURL(FileLocator.resolve(url))); } catch (URISyntaxException | IOException e) { e.printStackTrace(); } try { try { @@ -125,7 +126,7 @@ public class TransformationExecutor extends EpsilonStandalone { !packageETLFilesMarkedAsNotUsed(url.toString(), "core/")) { //(a) try { - etlFile = new File(FileLocator.resolve(url).toURI()); + etlFile = new File(resolveURL(FileLocator.resolve(url))); } catch (URISyntaxException | IOException e) { e.printStackTrace(); } try { try { @@ -154,7 +155,7 @@ public class TransformationExecutor extends EpsilonStandalone { public boolean packageMarkedAsNotUsed(String url, String sourceFolder) { url = url.substring(url.indexOf(sourceFolder) + sourceFolder.length()); url = url.substring(0, url.indexOf("/")); - if(url.startsWith("_") && url.endsWith("_")) return true; + if(url.startsWith("_")) return true; return false; } @@ -167,7 +168,7 @@ public class TransformationExecutor extends EpsilonStandalone { public boolean packageETLFilesMarkedAsNotUsed(String url, String sourceFolder) { url = url.substring(url.indexOf(sourceFolder) + sourceFolder.length()); url = url.substring(url.indexOf("/")+1, url.indexOf(".etl")); - if(url.startsWith("_") && url.endsWith("_")) return true; + if(url.startsWith("_")) return true; return false; } @@ -194,7 +195,7 @@ public class TransformationExecutor extends EpsilonStandalone { } else { //Step 2 try { - File ORM2CROMUrl = new File(FileLocator.resolve(ORM2CROMUrls.get(0)).toURI()); + File ORM2CROMUrl = new File(resolveURL(FileLocator.resolve(ORM2CROMUrls.get(0)))); BufferedReader buff = new BufferedReader(new FileReader(ORM2CROMUrl.getPath())); String str = ""; while ((str = buff.readLine()) != null) { @@ -319,4 +320,16 @@ public class TransformationExecutor extends EpsilonStandalone { return models; } + + /** + * Translator from URLs to URIs that creates correct URIs, in contrast to URL.toURI(). + * (cf. https://stackoverflow.com/questions/14676966/escape-result-of-filelocator-resolveurl/14677157) + * + * @param url the given URL + * @return a new correctly initialized URI object + * @throws URISyntaxException + */ + private static URI resolveURL(URL url) throws URISyntaxException { + return new URI(url.getProtocol(), url.getPath(), null); + } } diff --git a/org.framed.iorm.ui/core/model/ModelPattern.java b/org.framed.iorm.ui/core/model/ModelPattern.java index 44f614151976e6b4865b2c6b4861695638ca2856..5ed94d6a49fee7d836eb9093427edbc30b04b0b9 100644 --- a/org.framed.iorm.ui/core/model/ModelPattern.java +++ b/org.framed.iorm.ui/core/model/ModelPattern.java @@ -2,6 +2,8 @@ package model; import java.io.IOException; import java.net.URISyntaxException; +import java.net.URL; + import org.eclipse.core.runtime.FileLocator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; @@ -154,7 +156,7 @@ public class ModelPattern extends FRaMEDShapePattern implements IPattern { private void setStandartConfiguration(Model model) throws URISyntaxException, IOException { ResourceSet resourceSet = new ResourceSetImpl(); Resource resourceStandartConfiguration = - resourceSet.createResource(URI.createURI(FileLocator.resolve(UILiterals.URL_TO_STANDARD_CONFIGURATION).toURI().toString())); + resourceSet.createResource(URI.createFileURI(FileLocator.resolve(UILiterals.URL_TO_STANDARD_CONFIGURATION).getFile())); try { resourceStandartConfiguration.load(null); } catch (IOException e) { @@ -164,4 +166,5 @@ public class ModelPattern extends FRaMEDShapePattern implements IPattern { Model standardConfigurationModel = (Model) resourceStandartConfiguration.getContents().get(0); model.setFramedConfiguration(standardConfigurationModel.getFramedConfiguration()); } + } \ No newline at end of file diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/UIUtil.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/UIUtil.java index c3c08a5bee462f6885b842928c810dbd3ff480b0..5972c8b7aa8ffa640425b182f33f23c08891f1a3 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/UIUtil.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/UIUtil.java @@ -28,6 +28,7 @@ import org.eclipse.graphiti.features.IMappingProvider; import org.eclipse.graphiti.features.context.ICreateContext; import org.eclipse.graphiti.features.context.IReconnectionContext; import org.eclipse.graphiti.features.context.impl.AddContext; +import org.eclipse.graphiti.features.context.impl.CreateContext; import org.eclipse.graphiti.features.context.impl.ReconnectionContext; import org.eclipse.graphiti.mm.algorithms.Text; import org.eclipse.graphiti.mm.pictograms.Anchor; @@ -55,7 +56,14 @@ import org.framed.iorm.ui.exceptions.NoLinkedModelYet; import org.framed.iorm.ui.exceptions.NoModelFoundException; import org.framed.iorm.ui.multipage.MultipageEditor; import org.framed.iorm.ui.providers.ToolBehaviorProvider; -import org.framed.iorm.ui.references.*; +import org.framed.iorm.ui.references.AbstractAttributeAndOperationReference; +import org.framed.iorm.ui.references.AbstractGroupingFeatureReference; +import org.framed.iorm.ui.references.AbstractIntraRelationshipConstraintReference; +import org.framed.iorm.ui.references.AbstractModelFeatureReference; +import org.framed.iorm.ui.references.AbstractRelationshipFeatureReference; +import org.framed.iorm.ui.references.AbstractStepInReference; +import org.framed.iorm.ui.references.MoreThanOneFeatureReferenceFoundException; +import org.framed.iorm.ui.references.NotExactlyOneFeatureReferenceFoundException; import org.framed.iorm.ui.wizards.RoleModelWizard; import org.osgi.framework.Bundle; @@ -693,8 +701,9 @@ public class UIUtil { */ public static boolean packageMarkedAsNotUsed(String classURL, String sourceFolder) { classURL = classURL.substring(classURL.indexOf(sourceFolder) + sourceFolder.length()); - classURL = classURL.substring(0, classURL.indexOf("/")); - if(classURL.startsWith("_") && classURL.endsWith("_")) return true; + if (classURL.indexOf("/")>-1) + classURL = classURL.substring(0, classURL.indexOf("/")); + if(classURL.startsWith("_")) return true; return false; } @@ -1152,4 +1161,5 @@ public class UIUtil { public static String getGroupingFeaturesElementText(ModelElement modelElement) { return modelElement.getType().toString() + " " + modelElement.getName(); } + } diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/ConstraintRuleVisitor.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/ConstraintRuleVisitor.java index 1ff038cc0b0a12ad5835defb5fac1eda785e93d3..2e852cf148101478167f97870c0db518051377fe 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/ConstraintRuleVisitor.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/ConstraintRuleVisitor.java @@ -1,10 +1,15 @@ package org.framed.iorm.ui.editPolicy; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + import org.eclipse.graphiti.features.context.impl.AddConnectionContext; import org.eclipse.graphiti.features.context.impl.AddContext; import org.eclipse.graphiti.features.context.impl.CreateConnectionContext; import org.eclipse.graphiti.features.context.impl.CreateContext; import org.eclipse.graphiti.mm.pictograms.Anchor; +import org.eclipse.graphiti.mm.pictograms.ContainerShape; import org.eclipse.graphiti.mm.pictograms.Diagram; import org.eclipse.graphiti.mm.pictograms.Shape; import org.framed.iorm.model.ModelElement; @@ -24,45 +29,47 @@ import editpolicymodel.OrConstraintRule; import editpolicymodel.SourceEqualsTarget; import editpolicymodel.SourceEqualsTargetType; import editpolicymodel.TrueConstraintRule; -import compartment.AddCompartmentTypeContext; /** - * This class provides the rule-parse for the command-rules. Using VisitorPattern + * This class provides the rule-parse for the command-rules. Using + * VisitorPattern * * @author Christian Deussen * */ public class ConstraintRuleVisitor { + public Map<Type, String> groupingFeatureCache = new HashMap<Type, String>(); + /** * command to check rules against */ private Object context; - + @SuppressWarnings("unused") private Type type; private Diagram diagram; - + public ConstraintRuleVisitor(Object context, Type type, Diagram diagram) { this.context = context; this.type = type; this.diagram = diagram; } - - public Diagram getDiagramWithName(String name, Diagram rootDiagram) - { + + public Diagram getDiagramWithName(String name, Diagram rootDiagram) { Diagram containerDiagram = UIUtil.getContainerDiagramForAnyDiagram(rootDiagram); - if(containerDiagram == null) throw new NoDiagramFoundException(); - for(Shape shape : containerDiagram.getChildren()) { - if(shape instanceof Diagram) { - if(((Diagram) shape).getName().equals(name)) - return ((Diagram) shape); + if (containerDiagram == null) + throw new NoDiagramFoundException(); + for (Shape shape : containerDiagram.getChildren()) { + if (shape instanceof Diagram) { + if (((Diagram) shape).getName().equals(name)) + return ((Diagram) shape); } } return null; } - + /** * dispatch abstract rule * @@ -71,45 +78,44 @@ public class ConstraintRuleVisitor { * @param rule * @return Boolean */ - public boolean checkRule(ConstraintRule rule) - { - if(rule instanceof InCompartment) { - return isInCompartmentRuleVisitor((InCompartment)rule); + public boolean checkRule(ConstraintRule rule) { + if (rule instanceof InCompartment) { + return isInCompartmentRuleVisitor((InCompartment) rule); } - + if (rule instanceof AndConstraintRule) - return andRuleVisitor((AndConstraintRule)rule); - + return andRuleVisitor((AndConstraintRule) rule); + if (rule instanceof OrConstraintRule) - return orRuleVisitor((OrConstraintRule)rule); - + return orRuleVisitor((OrConstraintRule) rule); + if (rule instanceof NotConstraintRule) - return notRuleVisitor((NotConstraintRule)rule); - - if(rule instanceof IsSourceType) { - return isSourceTypeVisitor((IsSourceType)rule); + return notRuleVisitor((NotConstraintRule) rule); + + if (rule instanceof IsSourceType) { + return isSourceTypeVisitor((IsSourceType) rule); } - - if(rule instanceof SourceEqualsTargetType) { - return sourceEqualsTargetTypeVisitor((SourceEqualsTargetType)rule); + + if (rule instanceof SourceEqualsTargetType) { + return sourceEqualsTargetTypeVisitor((SourceEqualsTargetType) rule); } - - if(rule instanceof SourceEqualsTarget) { - return sourceEqualsTargetVisitor((SourceEqualsTarget)rule); + + if (rule instanceof SourceEqualsTarget) { + return sourceEqualsTargetVisitor((SourceEqualsTarget) rule); } - - if(rule instanceof IsTargetType) { - return isTargetTypeVisitor((IsTargetType)rule); + + if (rule instanceof IsTargetType) { + return isTargetTypeVisitor((IsTargetType) rule); } - - if(rule instanceof ContainsCompartment) { - return containsCompartmentVisitor((ContainsCompartment)rule); + + if (rule instanceof ContainsCompartment) { + return containsCompartmentVisitor((ContainsCompartment) rule); } - + if (rule instanceof TrueConstraintRule) { - return true; + return true; } - + if (rule instanceof FalseConstraintRule) { return false; } @@ -117,71 +123,94 @@ public class ConstraintRuleVisitor { System.out.println("checkRule for " + rule.getClass().toString() + " not implemented"); return true; } - + private boolean isInCompartmentRuleVisitor(InCompartment rule) { - org.framed.iorm.model.Shape parent = null; - if(this.context instanceof AddCompartmentTypeContext) { - AddCompartmentTypeContext ctx = (AddCompartmentTypeContext) context; - parent = ctx.getModelToLink().getParent(); - } else if(this.context instanceof AddContext) { - AddContext ctx = (AddContext) context; - Diagram contextDiagram = (Diagram)ctx.getTargetContainer(); - if(contextDiagram.getName().startsWith("compartmentType")) - return true; - } else if(this.context instanceof CreateContext) { - CreateContext ctx = (CreateContext) context; - if(ctx.getTargetContainer() instanceof Diagram) { - Diagram contextDiagram = (Diagram)ctx.getTargetContainer(); - if(contextDiagram.getName().startsWith("compartmentType")) - return true; - } + ContainerShape container = null; + if (this.context instanceof AddContext) { + container = ((AddContext) this.context).getTargetContainer(); + } else if (this.context instanceof CreateContext) { + container = ((CreateContext) this.context).getTargetContainer(); } - if(parent == null) { - //System.out.println("Parent null. Wrong context InCompartment(): " + this.context.getClass()); + if (container == null) return false; - } + // travers Containers to find the compartment type. + Diagram compartmentDiagram = findContainerDiagramOfType(container, Type.COMPARTMENT_TYPE); + return compartmentDiagram != null; + } - String parentDiagramName = null; - try { - parentDiagramName = parent.getContainer().getParent().getName(); - } catch (Exception e) {} - Diagram myDiagram = this.getDiagramWithName(parentDiagramName, this.diagram); - if(myDiagram == null) - return false; - if(myDiagram.getName().startsWith("compartmentType")) - return true; + /** + * Returns the grouping reference (diagram kind) of the given container type, if + * it exists. Note: this method is cached for better performance. + * + * @param type + * the IORM::Type of the container element + * @return the string reference of the diagram kind of the given container type + */ + private String getGroupingReference(Type type) { + if (groupingFeatureCache.containsKey(type)) + return groupingFeatureCache.get(type); + Optional<String> result = UIUtil.getGroupingFeatureReferences().stream().filter(a -> a.getModelType() == type) // rule.getType(); + .map(a -> a.getDiagramKind()).findFirst(); + if (!result.isPresent()) + return null; + groupingFeatureCache.put(type, result.get()); + return result.get(); + } - return false; + /** + * This method checks if the given container shape is a Diagram of the Diagram + * Kind of the given type. Otherwise, the method traverses the containers to + * find a suitable candidate, if any exists. + * + * @param sourceShape + * the ContainerShape to investigate + * @param type + * the IORM::Type of the container to look for + * @return the diagram of the correct diagram kind or null if no corresponding + * diagram was not found. + */ + public Diagram findContainerDiagramOfType(ContainerShape sourceShape, Type type) { + String groupingReference = getGroupingReference(type); + while ((sourceShape != null) && !((sourceShape instanceof Diagram) + && (UIUtil.isDiagram_KindValue((Diagram) sourceShape, groupingReference)))) { + sourceShape = sourceShape.getContainer(); + } + if (sourceShape == null) + return null; + if (sourceShape instanceof Diagram) + return (Diagram) sourceShape; + throw new IllegalStateException( + "Invariant violated! findDiagramOfType found a sourceShape that was not a Diagram."); } - + private boolean andRuleVisitor(AndConstraintRule rule) { - for(ConstraintRule abstractRule : rule.getRules()) { - if(!checkRule(abstractRule)) + for (ConstraintRule abstractRule : rule.getRules()) { + if (!checkRule(abstractRule)) return false; } return true; } - + private boolean isSourceTypeVisitor(IsSourceType rule) { Anchor sourceAnchor = this.getSourceAnchorFromContext(this.context); - if(sourceAnchor == null) { + if (sourceAnchor == null) { System.out.println("failed isSourceType() sourceAnchor== null, this.context: " + this.context.toString()); return false; } ModelElement source = UIUtil.getModelElementForAnchor(sourceAnchor); return rule.getType().getLiteral().equals(source.getType().getLiteral()); } - + private boolean isTargetTypeVisitor(IsTargetType rule) { Anchor anchor = this.getTargetAnchorFromContext(this.context); - if(anchor == null) { + if (anchor == null) { System.out.println("failed isTargetType() anchor== null, this.context: " + this.context.toString()); return false; } ModelElement source = UIUtil.getModelElementForAnchor(anchor); return rule.getType().getLiteral().equals(source.getType().getLiteral()); } - + private boolean containsCompartmentVisitor(ContainsCompartment rule) { System.out.println("containsCompartmentVisitor: TODO: " + this.diagram.getChildren().toString()); if(this.context instanceof CreateContext) { @@ -196,27 +225,27 @@ public class ConstraintRuleVisitor { } return false; } - + private boolean sourceEqualsTargetVisitor(SourceEqualsTarget rule) { - //System.out.println("class is: " + this.context.getClass()); + // System.out.println("class is: " + this.context.getClass()); Anchor sourceAnchor = this.getSourceAnchorFromContext(this.context); ModelElement source = UIUtil.getModelElementForAnchor(sourceAnchor); - + Anchor targetAnchor = this.getTargetAnchorFromContext(this.context); ModelElement target = UIUtil.getModelElementForAnchor(targetAnchor); - - if(targetAnchor == null || sourceAnchor == null) + + if (targetAnchor == null || sourceAnchor == null) return false; - return source.hashCode() == target.hashCode(); + return source.hashCode() == target.hashCode(); } private Anchor getSourceAnchorFromContext(Object context) { Anchor sourceAnchor = null; - if(this.context instanceof AddConnectionContext) { + if (this.context instanceof AddConnectionContext) { AddConnectionContext ctx = (AddConnectionContext) this.context; sourceAnchor = ctx.getSourceAnchor(); - } else if(this.context instanceof CreateConnectionContext) { + } else if (this.context instanceof CreateConnectionContext) { CreateConnectionContext ctx = (CreateConnectionContext) this.context; sourceAnchor = ctx.getSourceAnchor(); } @@ -225,44 +254,45 @@ public class ConstraintRuleVisitor { private Anchor getTargetAnchorFromContext(Object context) { Anchor anchor = null; - if(this.context instanceof AddConnectionContext) { + if (this.context instanceof AddConnectionContext) { AddConnectionContext ctx = (AddConnectionContext) this.context; anchor = ctx.getTargetAnchor(); - } else if(this.context instanceof CreateConnectionContext) { + } else if (this.context instanceof CreateConnectionContext) { CreateConnectionContext ctx = (CreateConnectionContext) this.context; anchor = ctx.getTargetAnchor(); } return anchor; } - + private boolean sourceEqualsTargetTypeVisitor(SourceEqualsTargetType rule) { - //System.out.println("class is: " + this.context.getClass()); + // System.out.println("class is: " + this.context.getClass()); try { Anchor sourceAnchor = this.getSourceAnchorFromContext(this.context); ModelElement source = UIUtil.getModelElementForAnchor(sourceAnchor); - + Anchor targetAnchor = this.getTargetAnchorFromContext(this.context); ModelElement target = UIUtil.getModelElementForAnchor(targetAnchor); - System.out.println("sourceEqualsTargetTypeVisitor comparison: " + source.getType().getLiteral() + " == " + target.getType().getLiteral()); + System.out.println("sourceEqualsTargetTypeVisitor comparison: " + source.getType().getLiteral() + " == " + + target.getType().getLiteral()); return target.getType().getLiteral().equals(source.getType().getLiteral()); - } catch(Exception e) { + } catch (Exception e) { System.out.println("failed sourceEqualsTargetVisitor: " + e.getMessage()); } - + return false; } - + private boolean orRuleVisitor(OrConstraintRule rule) { - for(ConstraintRule abstractRule : rule.getRules()) { - if(checkRule(abstractRule)) + for (ConstraintRule abstractRule : rule.getRules()) { + if (checkRule(abstractRule)) return true; } return false; } - + private boolean notRuleVisitor(NotConstraintRule rule) { return !checkRule(rule.getRule()); - } + } } diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/EditPolicyService.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/EditPolicyService.java index 52c5cf716cc11677c1b965c8fc63d458a6c041fe..2141a79b7d699a7220934c6af18b74c6c2721b73 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/EditPolicyService.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/editPolicy/EditPolicyService.java @@ -90,20 +90,6 @@ public class EditPolicyService { } } - /** - * checks if the package part of a file url starts and ends with an _ - * - * @param url - * the string url to check against - * @param sourceFolder - * the source folder in which the class is located in - * @return if the package part of a class url starts and ends with an _ - */ - private static boolean isPackageMarkedAsNotUsed(String url) { - url = url.substring(url.lastIndexOf('/')+1, url.length()); - return url.startsWith("_") && url.endsWith("_"); - } - private static void loadAllFiles() { Bundle UIBundle = Platform.getBundle("org.framed.iorm.ui"); @@ -117,14 +103,14 @@ public class EditPolicyService { if (moduleFileURLs != null) { for (URL url : moduleFileURLs) { - if (!isPackageMarkedAsNotUsed(url.toString())) { + if (!UIUtil.packageMarkedAsNotUsed(url.toString(), "modules/")) { loadEditPolicyFile(url.toString()); } } } if (coreFileURLs != null) { for (URL url : coreFileURLs) { - if (!isPackageMarkedAsNotUsed(url.toString())) { + if (!UIUtil.packageMarkedAsNotUsed(url.toString(), "core/")) { loadEditPolicyFile(url.toString()); } } diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/subeditors/FRaMEDFeatureEditor.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/subeditors/FRaMEDFeatureEditor.java index 9d187f29210406abbd8ff6dd3ad3e235ffcf2820..c8ba6e95f66bf3eb3d7b110b0b758175b1728017 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/subeditors/FRaMEDFeatureEditor.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/subeditors/FRaMEDFeatureEditor.java @@ -2,6 +2,7 @@ package org.framed.iorm.ui.subeditors; import java.io.File; import java.io.IOException; +import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.HashMap; @@ -160,7 +161,7 @@ public class FRaMEDFeatureEditor extends EditorPart { private IFeatureModel readFeatureModel() { File featureModelFile = null; try { - featureModelFile = new File(FileLocator.resolve(URL_TO_FEATUREMODEL).toURI()); + featureModelFile = new File(resolveURL(FileLocator.resolve(URL_TO_FEATUREMODEL))); } catch (URISyntaxException | IOException e) { e.printStackTrace(); } FeatureModelManager featureModelManager = FeatureModelManager.getInstance(featureModelFile.toPath()); if(featureModelManager.getLastProblems().containsError()) { @@ -185,6 +186,18 @@ public class FRaMEDFeatureEditor extends EditorPart { } } + /** + * Translator from URLs to URIs that creates correct URIs, in contrast to URL.toURI(). + * (cf. https://stackoverflow.com/questions/14676966/escape-result-of-filelocator-resolveurl/14677157) + * + * @param url the given URL + * @return a new correctly initialized URI object + * @throws URISyntaxException + */ + private static URI resolveURL(URL url) throws URISyntaxException { + return new URI(url.getProtocol(), url.getPath(), null); + } + //tree related operation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /**