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

towards preference page implementation

parent 953ec45a
......@@ -8,7 +8,9 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.ui,
org.eclipse.ui.ide,
fr.mem4csd.osatedim.viatra,
org.eclipse.viatra.query.runtime
org.eclipse.viatra.query.runtime,
org.osate.core,
org.osate.ui
Import-Package: org.eclipse.core.commands,
org.eclipse.core.resources,
org.eclipse.core.runtime,
......
package fr.mem4csd.osatedim.viatra.utils;
package fr.mem4csd.osatedim.ui;
import java.util.Arrays;
import java.util.Collections;
......
package fr.mem4csd.osatedim.ui;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.eclipse.emf.common.util.Enumerator;
public enum ComponentExtensionPreference implements Enumerator {
NONE_EXTENSION(0,"none","none"),
REQUIRED_EXTENSION(1,"required","required"),
ALWAYS_EXTENSION(2,"always","always");
public static final int NONE_EXTENSION_VALUE = 0;
public static final int REQUIRED_EXTENSION_VALUE = 1;
public static final int ALWAYS_EXTENSION_VALUE = 2;
private static final ComponentExtensionPreference[] VALUES_ARRAY = new ComponentExtensionPreference[] {NONE_EXTENSION, REQUIRED_EXTENSION, ALWAYS_EXTENSION};
public static final List<ComponentExtensionPreference> VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY));
public static ComponentExtensionPreference get(String literal) {
for (int i = 0; i < VALUES_ARRAY.length; ++i) {
ComponentExtensionPreference result = VALUES_ARRAY[i];
if (result.toString().equals(literal)) {
return result;
}
}
return null;
}
public static ComponentExtensionPreference getByName(String name) {
for (int i = 0; i < VALUES_ARRAY.length; ++i) {
ComponentExtensionPreference result = VALUES_ARRAY[i];
if (result.getName().equals(name)) {
return result;
}
}
return null;
}
public static ComponentExtensionPreference get(int value) {
switch(value) {
case NONE_EXTENSION_VALUE:
return NONE_EXTENSION;
case REQUIRED_EXTENSION_VALUE:
return REQUIRED_EXTENSION;
case ALWAYS_EXTENSION_VALUE:
return ALWAYS_EXTENSION;
}
return null;
}
private final int value;
private final String name;
private final String literal;
private ComponentExtensionPreference(int value, String name, String literal) {
this.value = value;
this.name = name;
this.literal = literal;
}
@Override
public String getName() {
return name;
}
@Override
public int getValue() {
return value;
}
@Override
public String getLiteral() {
return literal;
}
}
......@@ -10,6 +10,7 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
......@@ -21,6 +22,7 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
import org.eclipse.viatra.query.runtime.emf.EMFScope;
import org.osate.aadl2.instance.SystemInstance;
......@@ -29,7 +31,7 @@ import org.osate.aadl2.modelsupport.resources.OsateResourceUtil;
import fr.mem4csd.osatedim.viatra.transformations.DIMTransformationDeltaInplace;
public class DIMStartup implements IStartup, IPartListener {
public class DIMStartup extends AbstractUIPlugin implements IStartup, IPartListener {
private static DIMStartup instance = null;
......@@ -227,4 +229,17 @@ public class DIMStartup implements IStartup, IPartListener {
return null;
}
public static final String propertyInheritanceUtilityPreference = null;
public static final String deleteUnusedClassifierPreference = null;
public static final String classifierExtensionPreference = null;
public static final Boolean propertyInheritanceUtilityPreferenceDefault = true;
public static final Boolean collapseUnusedClassifierPreferenceDefault = false;
public static final Integer classifierExtensionPreferenceDefault = 0;
protected void initializeDefaultPreferences(IPreferenceStore store) {
store.setDefault(propertyInheritanceUtilityPreference,propertyInheritanceUtilityPreferenceDefault);
}
}
package fr.mem4csd.osatedim.ui;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.window.Window;
import java.util.ArrayList;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.osate.core.AadlNature;
import org.osate.core.OsateCorePlugin;
import org.osate.ui.dialogs.ProjectSelectionDialog;
public class DeinstantiationPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
public class DeinstantiationPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
private static final String LABEL = "Configure Project Specific Settings...";
private static final String TITLE = "Project Specific Configuration";
private static final String MESSAGE = "Select the project to configure:";
private static final String ID = "fr.mem4csd.osatedim.ui.InstantiationPropertyPage";
private static final String ID = "fr.mem4csd.osatedim.ui.DeinstantiationPropertyPage";
private static final String[] ID_LIST = { ID };
private static final Object DUMMY_DATA = new Object();
private Link changeWorkspaceSettings;
public DeinstantiationPreferencePage() {
super(GRID);
setPreferenceStore(OsateCorePlugin.getDefault().getPreferenceStore());
setDescription("AADL model instantiation preferences");
setPreferenceStore(DIMStartup.getInstance().getPreferenceStore());
setDescription("OSATE-DIM: AADL model deinstantiation preferences");
}
@Override
protected Label createDescriptionLabel(final Composite parent) {
changeWorkspaceSettings = createLink(parent, LABEL);
changeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
return super.createDescriptionLabel(parent);
}
private Link createLink(final Composite composite, final String text) {
Link link = new Link(composite, SWT.NONE);
link.setFont(composite.getFont());
......@@ -65,7 +60,24 @@ public class DeinstantiationPreferencePage extends PreferencePage implements IWo
});
return link;
}
/**
* Create the field editors.
*/
@Override
public void createFieldEditors() {
final BooleanFieldEditor propertyInheritanceUtilityField = new BooleanFieldEditor(DIMStartup.propertyInheritanceUtilityPreference,"Automatically add inherited properties to newly created instance elements", getFieldEditorParent());
addField(propertyInheritanceUtilityField);
final BooleanFieldEditor deleteUnusuedClassifierField = new BooleanFieldEditor(DIMStartup.deleteUnusedClassifierPreference,"Delete all unused classifiers created by OSATE-DIM (loss of delta information!)", getFieldEditorParent());
addField(deleteUnusuedClassifierField);
final RadioGroupFieldEditor classifierExtensionField = new RadioGroupFieldEditor(DIMStartup.classifierExtensionPreference,"Classifier extension preference",1, new String[][] {{"NONE",ComponentExtensionPreference.NONE_EXTENSION.getLiteral()},{"Structural changes",ComponentExtensionPreference.REQUIRED_EXTENSION.getLiteral()},{"Always",ComponentExtensionPreference.ALWAYS_EXTENSION.getLiteral()}},getFieldEditorParent());
addField(classifierExtensionField);
}
@Override
public void init(final IWorkbench workbench) {
}
final void doLinkActivated(final Link link) {
final ArrayList<IProject> projectsWithSpecifics = new ArrayList<>();
final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
......@@ -82,27 +94,5 @@ public class DeinstantiationPreferencePage extends PreferencePage implements IWo
PreferencesUtil.createPropertyDialogOn(getShell(), project, ID, ID_LIST, DUMMY_DATA).open();
}
}
public DeinstantiationPreferencePage(String title) {
super(title);
// TODO Auto-generated constructor stub
}
public DeinstantiationPreferencePage(String title, ImageDescriptor image) {
super(title, image);
// TODO Auto-generated constructor stub
}
@Override
public void init(IWorkbench workbench) {
// TODO Auto-generated method stub
}
@Override
protected Control createContents(Composite parent) {
// TODO Auto-generated method stub
return null;
}
}
package fr.mem4csd.osatedim.ui;
public class DeinstantiationPropertyPage {
}
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