Commit f976a279 authored by Rakshit Mittal's avatar Rakshit Mittal
Browse files

added/changed user preference options

parent dea461ff
......@@ -16,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, new DIMPreferences(false, false, false, "none"));
final DIMTransformationDeltaInplace transformation = new DIMTransformationDeltaInplace((SystemInstance) aaxlResource.getContents().get(0), engine, new DIMPreferences(false, false, false, false, "none"));
transformation.execute();
return transformation;
}
......
......@@ -18,7 +18,7 @@ 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, new DIMPreferences(false, false, false, "none"));
TransformationUtils.executeStateDIM(aaxlResource.getResourceSet(), topSystemInst, aadlPackage, aadlResource, new DIMPreferences(false, false, false, false, "none"));
System.out.println("DIM: State-based DIMTransformation finished corresponding to "+inputModelName+" instance model.");
}
......
......@@ -28,32 +28,36 @@ public class DIMUIPlugin extends AbstractUIPlugin{
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_ADD_CLASSIFIER_PROPERTY = "fr.mem4csd.osatedim.ui.add_classifier_property";
public static final String PREF_MODIFY_REUSED = "fr.mem4csd.osatedim.ui.modify_reused";
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 boolean ADD_CLASSIFIER_PROPERTY_DEFAULT = false;
public static final boolean MODIFY_REUSED_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(ADD_CLASSIFIER_PROPERTY_PROPERTY, ADD_CLASSIFIER_PROPERTY_DEFAULT);
store.setDefault(MODIFY_REUSED_PROPERTY, MODIFY_REUSED_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 ADD_CLASSIFIER_PROPERTY_PROPERTY = "addClassifierProperty";
public static final String MODIFY_REUSED_PROPERTY = "modifyReused";
public static final String EXTEND_CLASSIFIER_PROPERTY = "extendClassifier";
// Getter methods
public DIMPreferences getPreferences(IProject project) {
DIMPreferences preferences = new DIMPreferences(getInheritProperty(project), getInheritMode(project), getDeleteClassifier(project), getExtendClassifier(project));
DIMPreferences preferences = new DIMPreferences(getInheritProperty(project), getInheritMode(project), getAddClassifierProperty(project), getModifyReused(project), getExtendClassifier(project));
return preferences;
}
......@@ -79,14 +83,25 @@ public class DIMUIPlugin extends AbstractUIPlugin{
}
}
private final boolean getDeleteClassifier(IProject project) {
private final boolean getAddClassifierProperty(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);
return prefs.getBoolean(PREF_ADD_CLASSIFIER_PROPERTY, true);
} else {
IPreferenceStore store = getPreferenceStore();
return store.getBoolean(DELETE_CLASSIFIER_PROPERTY);
return store.getBoolean(ADD_CLASSIFIER_PROPERTY_PROPERTY);
}
}
private final boolean getModifyReused(IProject project) {
IScopeContext context = new ProjectScope(project);
Preferences prefs = context.getNode(PREFS_QUALIFIER);
if (!prefs.getBoolean(PREF_USE_WORKSPACE, true)) {
return prefs.getBoolean(PREF_MODIFY_REUSED, true);
} else {
IPreferenceStore store = getPreferenceStore();
return store.getBoolean(MODIFY_REUSED_PROPERTY);
}
}
......
......@@ -75,25 +75,35 @@ public class DeinstantiationPreferencePage extends FieldEditorPreferencePage imp
DIMUIPlugin.INHERIT_PROPERTY_PROPERTY,"AUTO-ADD INHERITED PROPERTIES to new instance elements", getFieldEditorParent());
addField(propertyInheritanceUtilityField);
addField(spacer0);
SpacerFieldEditor spacer1 = new SpacerFieldEditor(getFieldEditorParent());
addField(spacer1);
final BooleanFieldEditor modeInheritanceUtilityField = new BooleanFieldEditor(
DIMUIPlugin.INHERIT_MODE_PROPERTY,"AUTO-ADD INHERITED MODES to new instance elements", getFieldEditorParent());
addField(modeInheritanceUtilityField);
addField(spacer0);
DIMUIPlugin.INHERIT_MODE_PROPERTY,"AUTO-ADD INHERITED MODES to new instance elements", getFieldEditorParent());
addField(modeInheritanceUtilityField);
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 BooleanFieldEditor modifyReusedClassifierField = new BooleanFieldEditor(
DIMUIPlugin.MODIFY_REUSED_PROPERTY,"MODIFY multiply-used classifiers", getFieldEditorParent());
addField(modifyReusedClassifierField);
SpacerFieldEditor spacer3 = new SpacerFieldEditor(getFieldEditorParent());
addField(spacer3);
final BooleanFieldEditor addClassifierPropertyField = new BooleanFieldEditor(
DIMUIPlugin.ADD_CLASSIFIER_PROPERTY_PROPERTY,"ADD DIM_Classifier Property to newly created classifiers", getFieldEditorParent());
addField(addClassifierPropertyField);
SpacerFieldEditor spacer4 = new SpacerFieldEditor(getFieldEditorParent());
addField(spacer4);
final RadioGroupFieldEditor classifierExtensionField = new RadioGroupFieldEditor(
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());
{"ALWAYS",ClassifierExtensionPreference.ALWAYS_EXTENSION.getLiteral()}},getFieldEditorParent());
addField(classifierExtensionField);
}
......
......@@ -30,7 +30,10 @@ import fr.mem4csd.osatedim.viatra.preference.ClassifierExtensionPreference;
public class DeinstantiationPropertyPage extends PropertyPage {
private Button inheritPropertyButton;
private Button deleteClassifierButton;
private Button inheritModeButton;
private Button modifyReusedButton;
private Button addClassifierPropertyButton;
private Preferences preferences;
private Button noClassifierExtensionButton, requiredClassifierExtensionButton, alwaysClassifierExtensionButton;
......@@ -87,13 +90,29 @@ public class DeinstantiationPropertyPage extends PropertyPage {
label0.setText("AUTO-ADD INHERITED PROPERTIES to new instance elements");
label0.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
deleteClassifierButton = new Button(composite, SWT.CHECK);
deleteClassifierButton.setSelection(getDeleteClassifier());
deleteClassifierButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
inheritModeButton = new Button(composite, SWT.CHECK);
inheritModeButton.setSelection(getInheritMode());
inheritModeButton.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!)");
label1.setText("AUTO-ADD INHERITED MODES to new instance elements");
label1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
modifyReusedButton = new Button(composite, SWT.CHECK);
modifyReusedButton.setSelection(getModifyReused());
modifyReusedButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
final Label label2 = new Label(composite, SWT.NONE);
label2.setText("MODIFY multiply-used classifiers");
label2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
addClassifierPropertyButton = new Button(composite, SWT.CHECK);
addClassifierPropertyButton.setSelection(getAddClassifierProperty());
addClassifierPropertyButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
final Label label3 = new Label(composite, SWT.NONE);
label3.setText("ADD DIM_Classifier Property to newly created classifiers");
label3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
final Composite radioGroup1 = new Composite(composite, SWT.NONE);
radioGroup1.setLayout(new GridLayout());
......@@ -106,7 +125,7 @@ public class DeinstantiationPropertyPage extends PropertyPage {
requiredClassifierExtensionButton.setText("ONLY REQUIRED (Structural changes)");
alwaysClassifierExtensionButton = new Button(radioGroup1, SWT.RADIO);
alwaysClassifierExtensionButton.setText("ALWAYS (Recommended DELETE_UNUSED_CLASSIFIERS = true)");
alwaysClassifierExtensionButton.setText("ALWAYS");
if (getExtendClassifier() == "none") {
noClassifierExtensionButton.setSelection(true);
} else if (getExtendClassifier() == "required") {
......@@ -121,15 +140,18 @@ public class DeinstantiationPropertyPage extends PropertyPage {
useProjectSettingsButton.setSelection(false);
configureButton.setEnabled(true);
inheritPropertyButton.setEnabled(false);
deleteClassifierButton.setEnabled(false);
inheritModeButton.setEnabled(false);
modifyReusedButton.setEnabled(false);
addClassifierPropertyButton.setEnabled(false);
radioGroup1.setEnabled(false);
} else {
useWorkspaceSettingsButton.setSelection(false);
useProjectSettingsButton.setSelection(true);
configureButton.setEnabled(false);
inheritPropertyButton.setEnabled(true);
deleteClassifierButton.setEnabled(true);
inheritModeButton.setEnabled(true);
modifyReusedButton.setEnabled(true);
addClassifierPropertyButton.setEnabled(true);
radioGroup1.setEnabled(true);
}
......@@ -139,7 +161,9 @@ public class DeinstantiationPropertyPage extends PropertyPage {
public void widgetSelected(SelectionEvent e) {
configureButton.setEnabled(true);
inheritPropertyButton.setEnabled(false);
deleteClassifierButton.setEnabled(false);
inheritModeButton.setEnabled(false);
modifyReusedButton.setEnabled(false);
addClassifierPropertyButton.setEnabled(false);
radioGroup1.setEnabled(false);
}
});
......@@ -149,7 +173,9 @@ public class DeinstantiationPropertyPage extends PropertyPage {
public void widgetSelected(SelectionEvent e) {
configureButton.setEnabled(false);
inheritPropertyButton.setEnabled(true);
deleteClassifierButton.setEnabled(true);
inheritModeButton.setEnabled(true);
modifyReusedButton.setEnabled(true);
addClassifierPropertyButton.setEnabled(true);
radioGroup1.setEnabled(true);
}
});
......@@ -163,78 +189,93 @@ public class DeinstantiationPropertyPage extends PropertyPage {
// return the whole thing
return composite;
}
private boolean getInheritProperty() {
DIMUIPlugin.getInstance();
return preferences.getBoolean(DIMUIPlugin.PREF_INHERIT_PROPERTY, DIMUIPlugin.INHERIT_PROPERTY_DEFAULT);
}
private boolean getDeleteClassifier() {
DIMUIPlugin.getInstance();
return preferences.getBoolean(DIMUIPlugin.PREF_DELETE_CLASSIFIER, DIMUIPlugin.DELETE_CLASSIFIER_DEFAULT);
}
private String getExtendClassifier() {
DIMUIPlugin.getInstance();
return preferences.get(DIMUIPlugin.PREF_EXTEND_CLASSIFIER, DIMUIPlugin.EXTEND_CLASSIFIER_DEFAULT);
}
}
private boolean useWorkspacePreferences(IProject project) {
return preferences.getBoolean(DIMUIPlugin.PREF_USE_WORKSPACE, true);
}
private boolean getInheritProperty() {
DIMUIPlugin.getInstance();
return preferences.getBoolean(DIMUIPlugin.PREF_INHERIT_PROPERTY, DIMUIPlugin.INHERIT_PROPERTY_DEFAULT);
}
private boolean getInheritMode() {
DIMUIPlugin.getInstance();
return preferences.getBoolean(DIMUIPlugin.PREF_INHERIT_MODE, DIMUIPlugin.INHERIT_MODE_DEFAULT);
}
private boolean getModifyReused() {
DIMUIPlugin.getInstance();
return preferences.getBoolean(DIMUIPlugin.PREF_MODIFY_REUSED, DIMUIPlugin.MODIFY_REUSED_DEFAULT);
}
private boolean getAddClassifierProperty() {
DIMUIPlugin.getInstance();
return preferences.getBoolean(DIMUIPlugin.PREF_ADD_CLASSIFIER_PROPERTY, DIMUIPlugin.ADD_CLASSIFIER_PROPERTY_DEFAULT);
}
private String getExtendClassifier() {
DIMUIPlugin.getInstance();
return preferences.get(DIMUIPlugin.PREF_EXTEND_CLASSIFIER, DIMUIPlugin.EXTEND_CLASSIFIER_DEFAULT);
}
private boolean useWorkspacePreferences(IProject project) {
return preferences.getBoolean(DIMUIPlugin.PREF_USE_WORKSPACE, true);
}
@Override
public boolean performOk() {
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(DIMUIPlugin.PREF_EXTEND_CLASSIFIER, ClassifierExtensionPreference.ALWAYS_EXTENSION.getLiteral());
}
try {
preferences.flush();
} catch (final BackingStoreException e) {
e.printStackTrace();
}
return true;
@Override
public boolean performOk() {
preferences.putBoolean(DIMUIPlugin.PREF_USE_WORKSPACE, useWorkspaceSettingsButton.getSelection());
preferences.putBoolean(DIMUIPlugin.PREF_INHERIT_PROPERTY, inheritPropertyButton.getSelection());
preferences.putBoolean(DIMUIPlugin.PREF_INHERIT_MODE, inheritModeButton.getSelection());
preferences.putBoolean(DIMUIPlugin.PREF_MODIFY_REUSED, modifyReusedButton.getSelection());
preferences.putBoolean(DIMUIPlugin.PREF_ADD_CLASSIFIER_PROPERTY, addClassifierPropertyButton.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(DIMUIPlugin.PREF_EXTEND_CLASSIFIER, ClassifierExtensionPreference.ALWAYS_EXTENSION.getLiteral());
}
@Override
protected void performDefaults() {
useWorkspaceSettingsButton.setSelection(true);
useProjectSettingsButton.setSelection(false);
configureButton.setEnabled(true);
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();
try {
preferences.flush();
} catch (final BackingStoreException e) {
e.printStackTrace();
}
return true;
}
private void configureWorkspaceSettings() {
final IPreferencePage page = new InstantiationPreferencePage();
page.setTitle(getTitle());
final IPreferenceNode targetNode = new PreferenceNode("fr.mem4csd.osatedim.ui.preferencePage", page);
final PreferenceManager manager = new PreferenceManager();
manager.addToRoot(targetNode);
final PreferenceDialog dialog = new PreferenceDialog(getControl().getShell(), manager);
BusyIndicator.showWhile(getControl().getDisplay(), () -> {
dialog.create();
dialog.setMessage(targetNode.getLabelText());
dialog.open();
});
}
@Override
protected void performDefaults() {
useWorkspaceSettingsButton.setSelection(true);
useProjectSettingsButton.setSelection(false);
configureButton.setEnabled(true);
inheritPropertyButton.setSelection(DIMUIPlugin.INHERIT_PROPERTY_DEFAULT);
inheritPropertyButton.setEnabled(false);
inheritModeButton.setSelection(DIMUIPlugin.INHERIT_MODE_DEFAULT);
inheritModeButton.setEnabled(false);
modifyReusedButton.setSelection(DIMUIPlugin.MODIFY_REUSED_DEFAULT);
modifyReusedButton.setEnabled(false);
addClassifierPropertyButton.setSelection(DIMUIPlugin.ADD_CLASSIFIER_PROPERTY_DEFAULT);
addClassifierPropertyButton.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();
}
private void configureWorkspaceSettings() {
final IPreferencePage page = new InstantiationPreferencePage();
page.setTitle(getTitle());
final IPreferenceNode targetNode = new PreferenceNode("fr.mem4csd.osatedim.ui.preferencePage", page);
final PreferenceManager manager = new PreferenceManager();
manager.addToRoot(targetNode);
final PreferenceDialog dialog = new PreferenceDialog(getControl().getShell(), manager);
BusyIndicator.showWhile(getControl().getDisplay(), () -> {
dialog.create();
dialog.setMessage(targetNode.getLabelText());
dialog.open();
});
}
}
package fr.mem4csd.osatedim.viatra.preference;
public class DIMPreferences {
private final boolean inheritProperty, inheritMode, deleteClassifier;
private final boolean inheritProperty, inheritMode, addClassifierProperty, modifyReused;
private final String extendClassifier;
public DIMPreferences(boolean inheritProperty, boolean inheritMode, boolean deleteClassifier, String extendClassifier) {
this.deleteClassifier = deleteClassifier;
public DIMPreferences(boolean inheritProperty, boolean inheritMode, boolean modifyReused, boolean addClassifierProperty, String extendClassifier) {
this.addClassifierProperty = addClassifierProperty;
this.inheritMode = inheritMode;
this.inheritProperty = inheritProperty;
this.modifyReused = modifyReused;
this.extendClassifier = extendClassifier;
}
......@@ -19,12 +20,16 @@ public class DIMPreferences {
return inheritMode;
}
public boolean isDeleteClassifier() {
return deleteClassifier;
public boolean isAddClassifierProperty() {
return addClassifierProperty;
}
public String getExtendClassifier() {
return extendClassifier;
}
public boolean isModifyReused() {
return modifyReused;
}
}
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