Commit 78a151c5 authored by Rakshit Mittal's avatar Rakshit Mittal
Browse files

added mode inheritance preference

parent 45756815
......@@ -6,6 +6,7 @@ import org.eclipse.viatra.query.runtime.emf.EMFScope;
import org.junit.jupiter.api.Test;
import org.osate.aadl2.instance.SystemInstance;
import fr.mem4csd.osatedim.viatra.preference.DIMPreferences;
import fr.mem4csd.osatedim.viatra.transformations.DIMTransformationDeltaInplace;
public class TestDeltaInplace extends TestAbstract {
......@@ -15,7 +16,7 @@ public class TestDeltaInplace extends TestAbstract {
protected DIMTransformationDeltaInplace initiateDIMTransformationDeltaInplace(String inputModelName) {
prepareTestDeltaInplaceResources(inputModelName);
final ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(aaxlResource.getResourceSet()));
final DIMTransformationDeltaInplace transformation = new DIMTransformationDeltaInplace((SystemInstance) aaxlResource.getContents().get(0), engine);
final DIMTransformationDeltaInplace transformation = new DIMTransformationDeltaInplace((SystemInstance) aaxlResource.getContents().get(0), engine, new DIMPreferences(false, false, false, "none"));
transformation.execute();
return transformation;
}
......
......@@ -2,11 +2,13 @@ package fr.mem4csd.osatedim.tests;
import java.io.IOException;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.junit.jupiter.api.Test;
import org.osate.aadl2.AadlPackage;
import org.osate.aadl2.modelsupport.FileNameConstants;
import fr.mem4csd.osatedim.ui.utils.DeinstantiationUtils;
import fr.mem4csd.osatedim.viatra.preference.DIMPreferences;
import fr.mem4csd.osatedim.viatra.utils.PackageUtils;
import fr.mem4csd.osatedim.viatra.utils.TransformationUtils;
......@@ -16,13 +18,13 @@ public class TestState extends TestAbstract {
prepareTestStateResources(inputModelName);
AadlPackage aadlPackage = PackageUtils.configureAadlPackage(topSystemInst.eResource().getURI(), topSystemInst);
aadlResource.getContents().add(aadlPackage);
TransformationUtils.executeStateDIM(aaxlResource.getResourceSet(), topSystemInst, aadlPackage, aadlResource);
TransformationUtils.executeStateDIM(aaxlResource.getResourceSet(), topSystemInst, aadlPackage, aadlResource, new DIMPreferences(false, false, false, "none"));
System.out.println("DIM: State-based DIMTransformation finished corresponding to "+inputModelName+" instance model.");
}
protected static void prepareTestStateResources(String inputModelName) {
ResourceSet resSet = prepareTestResources(inputModelName);
resSet.getResource(topSystemInst.eResource().getURI().trimSegments(4).appendSegment( "RAMSES" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
Resource ramsesResource = resSet.getResource(topSystemInst.eResource().getURI().trimSegments(4).appendSegment( "RAMSES" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true );
final URI declarativeModelUri = DeinstantiationUtils.computeDeclarativeUri(aaxlResource.getURI(), topSystemInst);
aadlResource = resSet.createResource(declarativeModelUri);
}
......
......@@ -48,7 +48,7 @@ public class DIMStartup implements IStartup, IPartListener {
super();
instance = this;
transformationMap = new HashMap<URI, DIMTransformationDeltaInplace>();
syncPropQualName = new QualifiedName( getClass().getPackageName(), "synchronized" );
syncPropQualName = new QualifiedName( getClass().getPackage().getName(), "synchronized" );
}
@Override
......
......@@ -27,29 +27,33 @@ public class DIMUIPlugin extends AbstractUIPlugin{
public static final String PREFS_QUALIFIER = "fr.mem4csd.osatedim.ui";
public static final String PREF_USE_WORKSPACE = "fr.mem4csd.osatedim.ui.use_workspace";
public static final String PREF_INHERIT_PROPERTY = "fr.mem4csd.osatedim.ui.inherit_property";
public static final String PREF_INHERIT_MODE = "fr.mem4csd.osatedim.ui.inherit_mode";
public static final String PREF_DELETE_CLASSIFIER = "fr.mem4csd.osatedim.ui.delete_classifier";
public static final String PREF_EXTEND_CLASSIFIER = "fr.mem4csd.osatedim.ui.extend_classifier";
// Default Values
public static final boolean INHERIT_PROPERTY_DEFAULT = true;
public static final boolean INHERIT_MODE_DEFAULT = false;
public static final boolean DELETE_CLASSIFIER_DEFAULT = false;
public static final String EXTEND_CLASSIFIER_DEFAULT = ClassifierExtensionPreference.REQUIRED_EXTENSION.getLiteral();
@Override
protected void initializeDefaultPreferences(IPreferenceStore store) {
store.setDefault(INHERIT_PROPERTY_PROPERTY, INHERIT_PROPERTY_DEFAULT);
store.setDefault(INHERIT_MODE_PROPERTY, INHERIT_MODE_DEFAULT);
store.setDefault(DELETE_CLASSIFIER_PROPERTY, DELETE_CLASSIFIER_DEFAULT);
store.setDefault(EXTEND_CLASSIFIER_PROPERTY, EXTEND_CLASSIFIER_DEFAULT);
}
// Properties
public static final String INHERIT_PROPERTY_PROPERTY = "inheritProperty";
public static final String INHERIT_MODE_PROPERTY = "inheritMode";
public static final String DELETE_CLASSIFIER_PROPERTY = "deleteClassifier";
public static final String EXTEND_CLASSIFIER_PROPERTY = "extendClassifier";
// Getter methods
public DIMPreferences getPreferences(IProject project) {
DIMPreferences preferences = new DIMPreferences(getInheritProperty(project), getDeleteClassifier(project), getExtendClassifier(project));
DIMPreferences preferences = new DIMPreferences(getInheritProperty(project), getInheritMode(project), getDeleteClassifier(project), getExtendClassifier(project));
return preferences;
}
......@@ -64,6 +68,17 @@ public class DIMUIPlugin extends AbstractUIPlugin{
}
}
private final boolean getInheritMode(IProject project) {
IScopeContext context = new ProjectScope(project);
Preferences prefs = context.getNode(PREFS_QUALIFIER);
if (!prefs.getBoolean(PREF_USE_WORKSPACE, true)) {
return prefs.getBoolean(PREF_INHERIT_MODE, true);
} else {
final IPreferenceStore store = getPreferenceStore();
return store.getBoolean(INHERIT_MODE_PROPERTY);
}
}
private final boolean getDeleteClassifier(IProject project) {
IScopeContext context = new ProjectScope(project);
Preferences prefs = context.getNode(PREFS_QUALIFIER);
......
......@@ -68,25 +68,26 @@ public class DeinstantiationPreferencePage extends FieldEditorPreferencePage imp
*/
@Override
public void createFieldEditors() {
SpacerFieldEditor spacer0 = new SpacerFieldEditor(
getFieldEditorParent());
addField(spacer0);
SpacerFieldEditor spacer0 = new SpacerFieldEditor(getFieldEditorParent());
addField(spacer0);
final BooleanFieldEditor propertyInheritanceUtilityField = new BooleanFieldEditor(
DIMUIPlugin.INHERIT_PROPERTY_PROPERTY,"AUTO-ADD INHERITED PROPERTIES to new instance elements", getFieldEditorParent());
addField(propertyInheritanceUtilityField);
SpacerFieldEditor spacer1 = new SpacerFieldEditor(
getFieldEditorParent());
addField(spacer1);
addField(spacer0);
final BooleanFieldEditor modeInheritanceUtilityField = new BooleanFieldEditor(
DIMUIPlugin.INHERIT_MODE_PROPERTY,"AUTO-ADD INHERITED MODES to new instance elements", getFieldEditorParent());
addField(modeInheritanceUtilityField);
addField(spacer0);
final BooleanFieldEditor deleteUnusuedClassifierField = new BooleanFieldEditor(
DIMUIPlugin.DELETE_CLASSIFIER_PROPERTY,"DELETE UNUSED CLASSIFIERS created by OSATE-DIM (loss of delta information!)", getFieldEditorParent());
addField(deleteUnusuedClassifierField);
SpacerFieldEditor spacer2 = new SpacerFieldEditor(
getFieldEditorParent());
addField(spacer2);
addField(spacer0);
final RadioGroupFieldEditor classifierExtensionField = new RadioGroupFieldEditor(
DIMUIPlugin.EXTEND_CLASSIFIER_PROPERTY,"Classifier extension preference:",1,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment