Skip to content
Snippets Groups Projects
Commit e850d72a authored by Alberto Debiasi's avatar Alberto Debiasi
Browse files

Update ConstraintPreferencePage.

Change-Id: I2a4f44f22c7649a339b0fea67ed7b1355434d088
parent 168bd10f
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,6 @@ import java.util.ArrayList;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.polarsys.chess.core.constraint.ConstraintList;
......@@ -39,12 +38,11 @@ import org.polarsys.chess.core.Activator;
* preferences can be accessed directly via the preference store.
*/
public class ConstraintPreferencePage extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
public class ConstraintPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
/** The i. */
private static int i = 0;
/**
* Instantiates a new constraint preference page.
*/
......@@ -62,52 +60,64 @@ public class ConstraintPreferencePage extends FieldEditorPreferencePage
*/
public void createFieldEditors() {
ArrayList<FilterableConstraint> list = ConstraintList.getList();
if (list.isEmpty()) {
addField(new LabelField("Open the CHESS editor to load the constraints!", getFieldEditorParent()));
} else {
if (!list.isEmpty()) {
// addField(new LabelField("Open the CHESS editor to load the
// constraints!", getFieldEditorParent()));
// } else {
for (FilterableConstraint c : ConstraintList.getList()) {
IConstraint cc = c.getConstraint();
BooleanFieldEditor b = new BooleanFieldEditor(cc.getName(), cc.getMessage(), BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent());
BooleanFieldEditor b = new BooleanFieldEditor(cc.getName(), cc.getMessage(),
BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent());
addField(b);
}
BooleanFieldEditor b1 = new BooleanFieldEditor(PreferenceProperties.DIAGRAM_IN_VIEW, "Diagrams must be created inside the proper CHESS views", BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent());
addField(b1);
BooleanFieldEditor b2 = new BooleanFieldEditor(PreferenceProperties.PALETTES_IN_VIEW, "Hide Diagram Palettes according to the current CHESS views", BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent());
addField(b2);
}
BooleanFieldEditor b1 = new BooleanFieldEditor(PreferenceProperties.DIAGRAM_IN_VIEW,
"Diagrams must be created inside the proper CHESS views", BooleanFieldEditor.SEPARATE_LABEL,
getFieldEditorParent());
addField(b1);
BooleanFieldEditor b2 = new BooleanFieldEditor(PreferenceProperties.PALETTES_IN_VIEW,
"Hide Diagram Palettes according to the current CHESS views", BooleanFieldEditor.SEPARATE_LABEL,
getFieldEditorParent());
addField(b2);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
*/
//Actively set the filter values on the ConstraintList
// Actively set the filter values on the ConstraintList
@Override
public boolean performOk() {
super.performOk();
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
for (FilterableConstraint c : ConstraintList.getList()) {
// if (!(c instanceof ParsableConstraint))
// continue;
// if (!(c instanceof ParsableConstraint))
// continue;
IConstraint cc = c.getConstraint();
c.setActive(store.getBoolean(cc.getName()));
}
return true;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
@Override
public void init(IWorkbench workbench) {
setPreferenceStore(Activator.getDefault().getPreferenceStore());
setDescription("CHESS Core Constraints");
setDescription("CHESS Core Constraints");
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
*/
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment