Commit 775388f3 authored by Rakshit Mittal's avatar Rakshit Mittal
Browse files

refactored UI to be compatible with standalone mode

parent d7c915f8
......@@ -26,3 +26,4 @@ Export-Package: fr.mem4csd.osatedim.ui,
fr.mem4csd.osatedim.ui.utils
Bundle-ActivationPolicy: lazy
Bundle-Vendor: MEM4CSD Telecom Paris
Bundle-Activator: fr.mem4csd.osatedim.ui.DIMUIPlugin
......@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.emf.common.util.URI;
......@@ -28,7 +29,6 @@ import org.osate.aadl2.modelsupport.FileNameConstants;
import org.osate.aadl2.modelsupport.resources.OsateResourceUtil;
import fr.mem4csd.osatedim.ui.utils.DeinstantiationUtils;
import fr.mem4csd.osatedim.ui.utils.EditorUtils;
import fr.mem4csd.osatedim.viatra.preference.DeinstantiationPreference;
import fr.mem4csd.osatedim.viatra.transformations.DIMTransformationDeltaInplace;
public class DIMStartup implements IStartup, IPartListener {
......@@ -39,7 +39,6 @@ public class DIMStartup implements IStartup, IPartListener {
private final QualifiedName syncPropQualName;
private final Map<URI, DIMTransformationDeltaInplace> transformationMap;
private final DeinstantiationPreference preferenceStore;
public static DIMStartup getInstance() {
return instance;
......@@ -48,7 +47,6 @@ public class DIMStartup implements IStartup, IPartListener {
public DIMStartup() {
super();
instance = this;
preferenceStore = new DeinstantiationPreference();
transformationMap = new HashMap<URI, DIMTransformationDeltaInplace>();
syncPropQualName = new QualifiedName( getClass().getPackageName(), "synchronized" );
}
......@@ -119,7 +117,8 @@ public class DIMStartup implements IStartup, IPartListener {
throws CoreException {
final Resource resource = systInstance.eResource();
final ViatraQueryEngine engine = ViatraQueryEngine.on( new EMFScope( resource.getResourceSet() ) );
final DIMTransformationDeltaInplace transformation = new DIMTransformationDeltaInplace( systInstance, engine );
final IProject project = OsateResourceUtil.toIFile(systInstance.eResource().getURI()).getProject();
final DIMTransformationDeltaInplace transformation = new DIMTransformationDeltaInplace( systInstance, engine, DIMUIPlugin.getInstance().getPreferences(project) );
return registerTransformation( resource.getURI(), transformation );
}
......
package fr.mem4csd.osatedim.ui;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.service.prefs.Preferences;
import fr.mem4csd.osatedim.viatra.preference.ClassifierExtensionPreference;
import fr.mem4csd.osatedim.viatra.preference.DIMPreferences;
public class DIMUIPlugin extends AbstractUIPlugin{
private static DIMUIPlugin instance = null;
public DIMUIPlugin() {
instance = this;
initializeDefaultPreferences(getPreferenceStore());
}
public static DIMUIPlugin getInstance() {
return instance;
}
// Preference qualifiers
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_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 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(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 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));
return preferences;
}
private final boolean getInheritProperty(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_PROPERTY, true);
} else {
final IPreferenceStore store = getPreferenceStore();
return store.getBoolean(INHERIT_PROPERTY_PROPERTY);
}
}
private final boolean getDeleteClassifier(IProject project) {
IScopeContext context = new ProjectScope(project);
Preferences prefs = context.getNode(PREFS_QUALIFIER);
if (!prefs.getBoolean(PREF_USE_WORKSPACE, true)) {
return prefs.getBoolean(PREF_DELETE_CLASSIFIER, true);
} else {
IPreferenceStore store = getPreferenceStore();
return store.getBoolean(DELETE_CLASSIFIER_PROPERTY);
}
}
private final String getExtendClassifier(IProject project) {
IScopeContext context = new ProjectScope(project);
Preferences prefs = context.getNode(PREFS_QUALIFIER);
if (!prefs.getBoolean(PREF_USE_WORKSPACE, true)) {
return prefs.get(PREF_EXTEND_CLASSIFIER, null);
} else {
final IPreferenceStore store = getPreferenceStore();
return store.getString(EXTEND_CLASSIFIER_PROPERTY);
}
}
}
......@@ -21,7 +21,6 @@ import org.osate.core.AadlNature;
import org.osate.ui.dialogs.ProjectSelectionDialog;
import fr.mem4csd.osatedim.ui.utils.SpacerFieldEditor;
import fr.mem4csd.osatedim.viatra.preference.ClassifierExtensionPreference;
import fr.mem4csd.osatedim.viatra.preference.DeinstantiationPreference;
public class DeinstantiationPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
private static final String LABEL = "Configure Project Specific Settings...";
......@@ -35,7 +34,7 @@ public class DeinstantiationPreferencePage extends FieldEditorPreferencePage imp
public DeinstantiationPreferencePage() {
super(GRID);
setPreferenceStore(DeinstantiationPreference.getInstance().getPreferenceStore());
setPreferenceStore(DIMUIPlugin.getInstance().getPreferenceStore());
setDescription("OSATE-DIM: Deinstantiation Preferences");
}
......@@ -74,7 +73,7 @@ public class DeinstantiationPreferencePage extends FieldEditorPreferencePage imp
addField(spacer0);
final BooleanFieldEditor propertyInheritanceUtilityField = new BooleanFieldEditor(
DeinstantiationPreference.INHERIT_PROPERTY_PREFERENCE,"AUTO-ADD INHERITED PROPERTIES to new instance elements", getFieldEditorParent());
DIMUIPlugin.INHERIT_PROPERTY_PROPERTY,"AUTO-ADD INHERITED PROPERTIES to new instance elements", getFieldEditorParent());
addField(propertyInheritanceUtilityField);
SpacerFieldEditor spacer1 = new SpacerFieldEditor(
......@@ -82,7 +81,7 @@ public class DeinstantiationPreferencePage extends FieldEditorPreferencePage imp
addField(spacer1);
final BooleanFieldEditor deleteUnusuedClassifierField = new BooleanFieldEditor(
DeinstantiationPreference.DELETE_CLASSIFIER_PREFERENCE,"DELETE UNUSED CLASSIFIERS created by OSATE-DIM (loss of delta information!)", getFieldEditorParent());
DIMUIPlugin.DELETE_CLASSIFIER_PROPERTY,"DELETE UNUSED CLASSIFIERS created by OSATE-DIM (loss of delta information!)", getFieldEditorParent());
addField(deleteUnusuedClassifierField);
SpacerFieldEditor spacer2 = new SpacerFieldEditor(
......@@ -90,7 +89,7 @@ public class DeinstantiationPreferencePage extends FieldEditorPreferencePage imp
addField(spacer2);
final RadioGroupFieldEditor classifierExtensionField = new RadioGroupFieldEditor(
DeinstantiationPreference.EXTEND_CLASSIFIER_PREFERENCE,"Classifier extension preference:",1,
DIMUIPlugin.EXTEND_CLASSIFIER_PROPERTY,"Classifier extension preference:",1,
new String[][] {{"NONE",ClassifierExtensionPreference.NONE_EXTENSION.getLiteral()},
{"ONLY REQUIRED (Structural changes)",ClassifierExtensionPreference.REQUIRED_EXTENSION.getLiteral()},
{"ALWAYS (Recommended DELETE_UNUSED_CLASSIFIERS = true)",ClassifierExtensionPreference.ALWAYS_EXTENSION.getLiteral()}},getFieldEditorParent());
......
......@@ -25,18 +25,15 @@ import org.eclipse.ui.dialogs.PropertyPage;
import org.osate.ui.internal.preferences.InstantiationPreferencePage;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
import fr.mem4csd.osatedim.viatra.preference.ClassifierExtensionPreference;
import fr.mem4csd.osatedim.viatra.preference.DeinstantiationPreference;
import fr.mem4csd.osatedim.viatra.transformations.DIMTransformationRules;
public class DeinstantiationPropertyPage extends PropertyPage {
private Button inheritProperty;
private Button deleteClassifier;
private Button inheritPropertyButton;
private Button deleteClassifierButton;
private Preferences preferences;
private Button noClassifierExtension, requiredClassifierExtension, alwaysClassifierExtension;
private Button noClassifierExtensionButton, requiredClassifierExtensionButton, alwaysClassifierExtensionButton;
Button useWorkspaceSettingsButton;
Button useProjectSettingsButton;
......@@ -54,7 +51,7 @@ public class DeinstantiationPropertyPage extends PropertyPage {
// Get the project's preferences
final IScopeContext context = new ProjectScope(project);
preferences = context.getNode(DIMTransformationRules.PREFS_QUALIFIER);
preferences = context.getNode(DIMUIPlugin.PREFS_QUALIFIER);
// Create the overall composite to fill up
final Composite composite = new Composite(parent, SWT.NONE);
......@@ -82,17 +79,17 @@ public class DeinstantiationPropertyPage extends PropertyPage {
configureButton.setText("Configure Workspace Settings ...");
// Create the actual property fields that we want to edit
inheritProperty = new Button(composite, SWT.CHECK);
inheritProperty.setSelection(getInherentProperty());
inheritProperty.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
inheritPropertyButton = new Button(composite, SWT.CHECK);
inheritPropertyButton.setSelection(getInheritProperty());
inheritPropertyButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
final Label label0 = new Label(composite, SWT.NONE);
label0.setText("AUTO-ADD INHERITED PROPERTIES to new instance elements");
label0.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
deleteClassifier = new Button(composite, SWT.CHECK);
deleteClassifier.setSelection(getDeleteClassifier());
deleteClassifier.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
deleteClassifierButton = new Button(composite, SWT.CHECK);
deleteClassifierButton.setSelection(getDeleteClassifier());
deleteClassifierButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
final Label label1 = new Label(composite, SWT.NONE);
label1.setText("DELETE UNUSED CLASSIFIERS created by OSATE-DIM (loss of delta information!)");
......@@ -102,38 +99,37 @@ public class DeinstantiationPropertyPage extends PropertyPage {
radioGroup1.setLayout(new GridLayout());
radioGroup1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
noClassifierExtension = new Button(radioGroup1, SWT.RADIO);
noClassifierExtension.setText("NONE");
noClassifierExtensionButton = new Button(radioGroup1, SWT.RADIO);
noClassifierExtensionButton.setText("NONE");
requiredClassifierExtension = new Button(radioGroup1, SWT.RADIO);
requiredClassifierExtension.setText("ONLY REQUIRED (Structural changes)");
requiredClassifierExtensionButton = new Button(radioGroup1, SWT.RADIO);
requiredClassifierExtensionButton.setText("ONLY REQUIRED (Structural changes)");
alwaysClassifierExtension = new Button(radioGroup1, SWT.RADIO);
alwaysClassifierExtension.setText("ALWAYS (Recommended DELETE_UNUSED_CLASSIFIERS = true)");
alwaysClassifierExtensionButton = new Button(radioGroup1, SWT.RADIO);
alwaysClassifierExtensionButton.setText("ALWAYS (Recommended DELETE_UNUSED_CLASSIFIERS = true)");
if (getExtendClassifier() == "none") {
noClassifierExtension.setSelection(true);
noClassifierExtensionButton.setSelection(true);
} else if (getExtendClassifier() == "required") {
requiredClassifierExtension.setSelection(true);
requiredClassifierExtensionButton.setSelection(true);
} else {
alwaysClassifierExtension.setSelection(true);
alwaysClassifierExtensionButton.setSelection(true);
}
// Configure button status
if (useWorkspacePreferences()) {
// Configure property fields enabled status
if (useWorkspacePreferences(project)) {
useWorkspaceSettingsButton.setSelection(true);
useProjectSettingsButton.setSelection(false);
configureButton.setEnabled(true);
inheritProperty.setEnabled(false);
deleteClassifier.setEnabled(false);
inheritPropertyButton.setEnabled(false);
deleteClassifierButton.setEnabled(false);
radioGroup1.setEnabled(false);
} else {
useWorkspaceSettingsButton.setSelection(false);
useProjectSettingsButton.setSelection(true);
configureButton.setEnabled(false);
inheritProperty.setEnabled(true);
deleteClassifier.setEnabled(true);
inheritPropertyButton.setEnabled(true);
deleteClassifierButton.setEnabled(true);
radioGroup1.setEnabled(true);
}
......@@ -142,8 +138,8 @@ public class DeinstantiationPropertyPage extends PropertyPage {
@Override
public void widgetSelected(SelectionEvent e) {
configureButton.setEnabled(true);
inheritProperty.setEnabled(false);
deleteClassifier.setEnabled(false);
inheritPropertyButton.setEnabled(false);
deleteClassifierButton.setEnabled(false);
radioGroup1.setEnabled(false);
}
});
......@@ -152,8 +148,8 @@ public class DeinstantiationPropertyPage extends PropertyPage {
@Override
public void widgetSelected(SelectionEvent e) {
configureButton.setEnabled(false);
inheritProperty.setEnabled(true);
deleteClassifier.setEnabled(true);
inheritPropertyButton.setEnabled(true);
deleteClassifierButton.setEnabled(true);
radioGroup1.setEnabled(true);
}
});
......@@ -169,33 +165,36 @@ public class DeinstantiationPropertyPage extends PropertyPage {
return composite;
}
private boolean getInherentProperty() {
return preferences.getBoolean(DIMTransformationRules.PREF_INHERIT_PROPERTY, DeinstantiationPreference.getInstance().getInheritProperty());
private boolean getInheritProperty() {
DIMUIPlugin.getInstance();
return preferences.getBoolean(DIMUIPlugin.PREF_INHERIT_PROPERTY, DIMUIPlugin.INHERIT_PROPERTY_DEFAULT);
}
private boolean getDeleteClassifier() {
return preferences.getBoolean(DIMTransformationRules.PREF_DELETE_CLASSIFIER, DeinstantiationPreference.getInstance().getDeleteClassifier());
DIMUIPlugin.getInstance();
return preferences.getBoolean(DIMUIPlugin.PREF_DELETE_CLASSIFIER, DIMUIPlugin.DELETE_CLASSIFIER_DEFAULT);
}
private String getExtendClassifier() {
return preferences.get(DIMTransformationRules.PREF_EXTEND_CLASSIFIER, DeinstantiationPreference.getInstance().getExtendClassifier());
DIMUIPlugin.getInstance();
return preferences.get(DIMUIPlugin.PREF_EXTEND_CLASSIFIER, DIMUIPlugin.EXTEND_CLASSIFIER_DEFAULT);
}
private boolean useWorkspacePreferences() {
return preferences.getBoolean(DIMTransformationRules.PREF_USE_WORKSPACE, true);
private boolean useWorkspacePreferences(IProject project) {
return preferences.getBoolean(DIMUIPlugin.PREF_USE_WORKSPACE, true);
}
@Override
public boolean performOk() {
preferences.putBoolean(DIMTransformationRules.PREF_USE_WORKSPACE, useWorkspaceSettingsButton.getSelection());
preferences.putBoolean(DIMTransformationRules.PREF_INHERIT_PROPERTY, inheritProperty.getSelection());
preferences.putBoolean(DIMTransformationRules.PREF_DELETE_CLASSIFIER, deleteClassifier.getSelection());
if (noClassifierExtension.getSelection()) {
preferences.put(DIMTransformationRules.PREF_EXTEND_CLASSIFIER, ClassifierExtensionPreference.NONE_EXTENSION.getLiteral());
} else if (requiredClassifierExtension.getSelection()) {
preferences.put(DIMTransformationRules.PREF_EXTEND_CLASSIFIER, ClassifierExtensionPreference.REQUIRED_EXTENSION.getLiteral());
preferences.putBoolean(DIMUIPlugin.PREF_USE_WORKSPACE, useWorkspaceSettingsButton.getSelection());
preferences.putBoolean(DIMUIPlugin.PREF_INHERIT_PROPERTY, inheritPropertyButton.getSelection());
preferences.putBoolean(DIMUIPlugin.PREF_DELETE_CLASSIFIER, deleteClassifierButton.getSelection());
if (noClassifierExtensionButton.getSelection()) {
preferences.put(DIMUIPlugin.PREF_EXTEND_CLASSIFIER, ClassifierExtensionPreference.NONE_EXTENSION.getLiteral());
} else if (requiredClassifierExtensionButton.getSelection()) {
preferences.put(DIMUIPlugin.PREF_EXTEND_CLASSIFIER, ClassifierExtensionPreference.REQUIRED_EXTENSION.getLiteral());
} else {
preferences.put(DIMTransformationRules.PREF_EXTEND_CLASSIFIER, ClassifierExtensionPreference.ALWAYS_EXTENSION.getLiteral());
preferences.put(DIMUIPlugin.PREF_EXTEND_CLASSIFIER, ClassifierExtensionPreference.ALWAYS_EXTENSION.getLiteral());
}
try {
preferences.flush();
......@@ -210,16 +209,16 @@ public class DeinstantiationPropertyPage extends PropertyPage {
useWorkspaceSettingsButton.setSelection(true);
useProjectSettingsButton.setSelection(false);
configureButton.setEnabled(true);
inheritProperty.setSelection(true);
inheritProperty.setEnabled(false);
deleteClassifier.setSelection(false);
deleteClassifier.setEnabled(false);
noClassifierExtension.setSelection(false);
requiredClassifierExtension.setSelection(true);
alwaysClassifierExtension.setSelection(false);
noClassifierExtension.setEnabled(false);
requiredClassifierExtension.setEnabled(false);
alwaysClassifierExtension.setEnabled(false);
inheritPropertyButton.setSelection(true);
inheritPropertyButton.setEnabled(false);
deleteClassifierButton.setSelection(false);
deleteClassifierButton.setEnabled(false);
noClassifierExtensionButton.setSelection(false);
requiredClassifierExtensionButton.setSelection(true);
alwaysClassifierExtensionButton.setSelection(false);
noClassifierExtensionButton.setEnabled(false);
requiredClassifierExtensionButton.setEnabled(false);
alwaysClassifierExtensionButton.setEnabled(false);
// Why? Because the default implementation does this
updateApplyButton();
}
......
......@@ -4,6 +4,7 @@ import java.io.IOException;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
......@@ -12,7 +13,9 @@ import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.viatra.query.runtime.exception.ViatraQueryException;
import org.osate.aadl2.AadlPackage;
import org.osate.aadl2.instance.SystemInstance;
import org.osate.aadl2.modelsupport.resources.OsateResourceUtil;
import fr.mem4csd.osatedim.ui.DIMUIPlugin;
import fr.mem4csd.osatedim.ui.utils.DeinstantiationUtils;
import fr.mem4csd.osatedim.viatra.utils.PackageUtils;
import fr.mem4csd.osatedim.viatra.utils.TransformationUtils;
......@@ -27,13 +30,14 @@ public class StateDeinstatiationHandler extends AbstractHandler {
final AadlPackage aadlPackage = PackageUtils.configureAadlPackage(selectionURI, topSystemInst);
final URI aadlURI = DeinstantiationUtils.computeDeclarativeUri(selectionURI, topSystemInst);
final ResourceSet resSet = topSystemInst.eResource().getResourceSet();
final Resource aadlResource = resSet.createResource(aadlURI);
final Resource aadlResource = resSet.createResource(aadlURI);
final IProject project = OsateResourceUtil.toIFile(aadlResource.getURI()).getProject();
aadlResource.getContents().add(aadlPackage);
System.out.println("DIM: Initializing static deinstantiation");
try {
TransformationUtils.executeStateDIM(resSet, topSystemInst, aadlPackage, aadlResource);
TransformationUtils.executeStateDIM(resSet, topSystemInst, aadlPackage, aadlResource, DIMUIPlugin.getInstance().getPreferences(project));
System.out.println("DIM: Static deinstantiation finished");
}
catch ( final ViatraQueryException | IOException ex ) {
......
package fr.mem4csd.osatedim.viatra.preference;
public class DIMPreferences {
private final boolean inheritProperty, deleteClassifier;
private final String extendClassifier;
public DIMPreferences(boolean inheritProperty, boolean deleteClassifier, String extendClassifier) {
this.deleteClassifier = deleteClassifier;
this.inheritProperty = inheritProperty;
this.extendClassifier = extendClassifier;
}
public boolean isInheritProperty() {
return inheritProperty;
}
public boolean isDeleteClassifier() {
return deleteClassifier;
}
public String getExtendClassifier() {
return extendClassifier;
}
}
package fr.mem4csd.osatedim.viatra.preference;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.plugin.AbstractUIPlugin;
public class DeinstantiationPreference extends AbstractUIPlugin{
private static DeinstantiationPreference instance = null;
public DeinstantiationPreference() {
instance = this;
initializeDefaultPreferences(getPreferenceStore());
}
public static final String INHERIT_PROPERTY_PREFERENCE = "inheritProperty";
public static final String DELETE_CLASSIFIER_PREFERENCE = "deleteClassifier";
public static final String EXTEND_CLASSIFIER_PREFERENCE = "extendClassifier";
public static final boolean INHERIT_PROPERTY_DEFAULT = true;
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_PREFERENCE,INHERIT_PROPERTY_DEFAULT);
store.setDefault(DELETE_CLASSIFIER_PREFERENCE, DELETE_CLASSIFIER_DEFAULT);
store.setDefault(EXTEND_CLASSIFIER_PREFERENCE, EXTEND_CLASSIFIER_DEFAULT);
}
public final boolean getInheritProperty() {
final IPreferenceStore store = getPreferenceStore();
return store.getBoolean(INHERIT_PROPERTY_PREFERENCE);
}
public final boolean getDeleteClassifier() {
final IPreferenceStore store = getPreferenceStore();
return store.getBoolean(DELETE_CLASSIFIER_PREFERENCE);
}
public final String getExtendClassifier() {
final IPreferenceStore store = getPreferenceStore();
return store.getString(EXTEND_CLASSIFIER_PREFERENCE);
}
public static DeinstantiationPreference getInstance() {
return instance;
}
}
......@@ -32,22 +32,24 @@ import org.osate.aadl2.instance.SystemOperationMode
import org.osate.aadl2.ModalPropertyValue
import org.osate.aadl2.modelsupport.util.AadlUtil
import org.osate.aadl2.PropertySet
import org.osate.aadl2.modelsupport.resources.OsateResourceUtil
import fr.mem4csd.osatedim.viatra.preference.DIMPreferences
class DIMTransformationDeltaInplace extends DIMTransformationRules{
extension EventDrivenTransformation transformation
protected PublicPackageSection aadlPackage
new(SystemInstance topSystemInst, ViatraQueryEngine engine) {
new(SystemInstance topSystemInst, ViatraQueryEngine engine, DIMPreferences preferences) {
this.topSystemInst = topSystemInst
this.aadlPackage = topSystemInst.componentClassifier.owner as PublicPackageSection
this.engine = engine
this.preferences = preferences;
componentRules = new DIMTransformationRulesComponent
featureRules = new DIMTransformationRulesFeature
connectionRules = new DIMTransformationRulesConnection
modeRules = new DIMTransformationRulesMode
propertyRules = new DIMTransformationRulesProperty
transformationUtils = new DIMTransformationUtils
transformationUtils = new DIMTransformationRulesExtension
prepare(engine)
createTransformation
}
......@@ -57,7 +59,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
DIMTransformationRulesConnection connectionRules
DIMTransformationRulesMode modeRules
DIMTransformationRulesProperty propertyRules
DIMTransformationUtils transformationUtils
DIMTransformationRulesExtension transformationUtils
def execute() {
transformation.executionSchema.startUnscheduledExecution
......@@ -113,8 +115,8 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val componentInstance2Declarative = createRule(FindSubcomponent.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if (subcompinst.subcomponent === null) {
componentRules.componentInstanceCreatedDIM(subcompinst)
if (getInheritProperty(OsateResourceUtil.toIFile(topSystemInst.eResource.URI).getProject())) {
componentRules.componentInstanceCreatedDIM(subcompinst, aadlPackage)
if (preferences.isInheritProperty()) {
transformationUtils.elementCreationPropertyInheritance(subcompinst, propertyRules)
}
println("DIM: Component instance "+subcompinst.name+" de-instantiated")
......@@ -138,7 +140,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
.action(CRUDActivationStateEnum.CREATED) [
if (featinst.feature === null) {
featureRules.featureInstanceCreatedDIM(featinst)
if (getInheritProperty(OsateResourceUtil.toIFile(topSystemInst.eResource.URI).getProject())) {
if (preferences.isInheritProperty) {
transformationUtils.elementCreationPropertyInheritance(featinst, propertyRules)
}
println("DIM: Feature instance "+featinst.name+" de-instantiated")
......@@ -171,7 +173,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
.action(CRUDActivationStateEnum.CREATED) [
if (conninst.connectionReferences.size < InstanceHierarchyUtils.getPathBetweenComponentInstance(conninst.source.eContainer as ComponentInstance,conninst.destination.eContainer as ComponentInstance).size) {
connectionRules.connectionInstanceCreatedDIM(conninst, featureRules)
if (getInheritProperty(OsateResourceUtil.toIFile(topSystemInst.eResource.URI).getProject())) {
if (preferences.isInheritProperty) {
transformationUtils.elementCreationPropertyInheritance(conninst, propertyRules)
}
println("DIM: Connection instance "+conninst.name+" de-instantiated")
......@@ -223,7 +225,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
.action(CRUDActivationStateEnum.CREATED) [