summaryrefslogtreecommitdiffstats
path: root/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets')
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java157
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Entries4
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Repository1
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Root1
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Tag1
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java86
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java100
-rw-r--r--org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java261
8 files changed, 611 insertions, 0 deletions
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java
new file mode 100644
index 0000000..cc2f966
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Alena Laskavaia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alena Laskavaia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.ui.widgets;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.osgi.util.TextProcessor;
+import org.eclipse.ui.IWorkingSet;
+
+/**
+ * A label provider for basic elements like paths. The label provider will make
+ * sure that the labels are correctly
+ * shown in RTL environments.
+ *
+ * @since 3.4
+ */
+public class BasicElementLabels {
+ // TextProcessor delimiters
+ private static final String CODE_DELIMITERS = TextProcessor
+ .getDefaultDelimiters() + "<>()?,{}+-*!%=^|&;[]~"; //$NON-NLS-1$
+ private static final String FILE_PATTERN_DELIMITERS = TextProcessor
+ .getDefaultDelimiters() + "*.?"; //$NON-NLS-1$
+ private static final String URL_DELIMITERS = TextProcessor
+ .getDefaultDelimiters() + ":@?-"; //$NON-NLS-1$
+
+ /**
+ * Returns the label of a path.
+ *
+ * @param path
+ * the path
+ * @param isOSPath
+ * if <code>true</code>, the path represents an OS path, if
+ * <code>false</code> it is a workspace path.
+ * @return the label of the path to be used in the UI.
+ */
+ public static String getPathLabel(IPath path, boolean isOSPath) {
+ String label;
+ if (isOSPath) {
+ label = path.toOSString();
+ } else {
+ label = path.makeRelative().toString();
+ }
+ return markLTR(label);
+ }
+
+ /**
+ * Returns the label of the path of a file.
+ *
+ * @param file
+ * the file
+ * @return the label of the file path to be used in the UI.
+ */
+ public static String getPathLabel(File file) {
+ return markLTR(file.getAbsolutePath());
+ }
+
+ /**
+ * Returns the label for a file pattern like '*.java'
+ *
+ * @param name
+ * the pattern
+ * @return the label of the pattern.
+ */
+ public static String getFilePattern(String name) {
+ return markLTR(name, FILE_PATTERN_DELIMITERS);
+ }
+
+ /**
+ * Returns the label for a URL, URI or URL part. Example is
+ * 'http://www.x.xom/s.html#1'
+ *
+ * @param name
+ * the URL string
+ * @return the label of the URL.
+ */
+ public static String getURLPart(String name) {
+ return markLTR(name, URL_DELIMITERS);
+ }
+
+ /**
+ * Returns a label for a resource name.
+ *
+ * @param resource
+ * the resource
+ * @return the label of the resource name.
+ */
+ public static String getResourceName(IResource resource) {
+ return markLTR(resource.getName());
+ }
+
+ /**
+ * Returns a label for a resource name.
+ *
+ * @param resourceName
+ * the resource name
+ * @return the label of the resource name.
+ */
+ public static String getResourceName(String resourceName) {
+ return markLTR(resourceName);
+ }
+
+ /**
+ * Returns a label for Java code snippet used in a label. Example is 'Test
+ * test= new Test<? extends List>() { ...}'.
+ *
+ * @param string
+ * the Java code snippet
+ * @return the label for the Java code snippet
+ */
+ public static String getJavaCodeString(String string) {
+ return markLTR(string, CODE_DELIMITERS);
+ }
+
+ /**
+ * Returns a label for a version name. Example is '1.4.1'
+ *
+ * @param name
+ * the version string
+ * @return the version label
+ */
+ public static String getVersionName(String name) {
+ return markLTR(name);
+ }
+
+ /**
+ * Returns a label for a working set
+ *
+ * @param set
+ * the working set
+ * @return the label of the working set
+ */
+ public static String getWorkingSetLabel(IWorkingSet set) {
+ return markLTR(set.getLabel());
+ }
+
+ /**
+ * It does not do anything now, but just in case we need to do the same as
+ * JDT does (see String.markLTR in JDT)
+ */
+ private static String markLTR(String label) {
+ return label;
+ }
+
+ private static String markLTR(String label, String delim) {
+ return label;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Entries
new file mode 100644
index 0000000..6bad80f
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Entries
@@ -0,0 +1,4 @@
+/BasicElementLabels.java/1.2/Thu Jun 3 17:01:40 2010//TCDT_7_0_0
+/CustomizeProblemComposite.java/1.2/Thu Jun 3 17:01:40 2010//TCDT_7_0_0
+/FileScopeComposite.java/1.2/Thu Jun 3 17:01:40 2010//TCDT_7_0_0
+/ParametersComposite.java/1.2/Thu Jun 3 17:01:40 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Repository b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Repository
new file mode 100644
index 0000000..905430a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Root b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java
new file mode 100644
index 0000000..32ba550
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Alena Laskavaia
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alena Laskavaia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.ui.widgets;
+
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+/**
+ * Composite for problem customisable parameters
+ *
+ */
+public class CustomizeProblemComposite extends Composite {
+ private Composite parametersTab;
+ private IProblem problem;
+ private ParametersComposite problemsComposite;
+ private FileScopeComposite scopeComposite;
+ private IResource resource;
+
+ /**
+ * @param parent
+ * @param selectedProblem
+ * @param resource
+ * @param style
+ */
+ public CustomizeProblemComposite(Composite parent,
+ IProblem selectedProblem, IResource resource) {
+ super(parent, SWT.NONE);
+ this.setLayout(new GridLayout(1, false));
+ this.problem = selectedProblem;
+ this.resource = resource;
+ final TabFolder tabFolder = new TabFolder(this, SWT.TOP);
+ tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+ // createMainTab(tabFolder);
+ createParamtersTab(tabFolder);
+ createScopeTab(tabFolder);
+ }
+
+ public void save(IProblemWorkingCopy problem) {
+ problemsComposite.save(problem);
+ scopeComposite.save(problem);
+ }
+
+ /**
+ * @param tabFolder
+ */
+ private void createParamtersTab(TabFolder tabFolder) {
+ TabItem tabItem1 = new TabItem(tabFolder, SWT.NULL);
+ tabItem1.setText(CodanUIMessages.CustomizeProblemComposite_TabParameters);
+ parametersTab = new Composite(tabFolder, SWT.NONE);
+ tabItem1.setControl(parametersTab);
+ parametersTab.setLayout(new GridLayout());
+ problemsComposite = new ParametersComposite(parametersTab, problem);
+ problemsComposite.setLayoutData(new GridData(SWT.BEGINNING,
+ SWT.BEGINNING, true, false));
+ }
+
+ /**
+ * @param tabFolder
+ */
+ private void createScopeTab(TabFolder tabFolder) {
+ TabItem tabItem1 = new TabItem(tabFolder, SWT.NULL);
+ tabItem1.setText(CodanUIMessages.CustomizeProblemComposite_TabScope);
+ Composite comp = new Composite(tabFolder, SWT.NONE);
+ tabItem1.setControl(comp);
+ comp.setLayout(new GridLayout());
+ scopeComposite = new FileScopeComposite(comp, problem, resource);
+ scopeComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING,
+ true, false));
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java
new file mode 100644
index 0000000..1a8536c
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Alena Laskavaia
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alena Laskavaia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.ui.widgets;
+
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
+import org.eclipse.cdt.codan.core.param.MapProblemPreference;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.cdt.codan.internal.ui.preferences.FileScopePreferencePage;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * Composite to show problem scope
+ *
+ */
+public class FileScopeComposite extends Composite {
+ private FileScopePreferencePage page;
+ private IProblem problem;
+ private PreferenceStore prefStore;
+ private FileScopeProblemPreference scope;
+
+ /**
+ * @param parent
+ * @param problem
+ * @param resource
+ * @param style
+ */
+ public FileScopeComposite(Composite parent, final IProblem problem,
+ IResource resource) {
+ super(parent, SWT.NONE);
+ if (problem == null)
+ throw new NullPointerException();
+ this.setLayout(new GridLayout(2, false));
+ this.problem = problem;
+ this.prefStore = new PreferenceStore();
+ IProblemPreference info = problem.getPreference();
+ FileScopeProblemPreference scopeIn = null;
+ if (info == null
+ || (!(info instanceof MapProblemPreference))
+ || ((scopeIn = (FileScopeProblemPreference) ((MapProblemPreference) info)
+ .getChildDescriptor(FileScopeProblemPreference.KEY)) == null)) {
+ Label label = new Label(this, 0);
+ label.setText(CodanUIMessages.ParametersComposite_None);
+ return;
+ }
+ scope = (FileScopeProblemPreference) scopeIn.clone();
+ scope.setResource(resource);
+ initPrefStore();
+ page = new FileScopePreferencePage(scope);
+ page.setPreferenceStore(prefStore);
+ page.noDefaultAndApplyButton();
+ page.createControl(parent);
+ page.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+
+ public void save(IProblemWorkingCopy problem) {
+ if (page != null)
+ page.performOk();
+ savePrefStore();
+ }
+
+ private void savePrefStore() {
+ if (scope == null)
+ return;
+ String key = scope.getQualifiedKey();
+ ((MapProblemPreference) problem.getPreference()).setChildValue(
+ FileScopeProblemPreference.KEY, scope);
+ prefStore.setValue(key, scope.exportValue());
+ }
+
+ private void initPrefStore() {
+ if (scope == null)
+ return;
+ String key = scope.getQualifiedKey();
+ prefStore.setValue(key, scope.exportValue());
+ }
+
+ /**
+ * @return the problem
+ */
+ public IProblem getProblem() {
+ return problem;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java
new file mode 100644
index 0000000..26e58fc
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Alena Laskavaia
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alena Laskavaia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.ui.widgets;
+
+import java.io.File;
+
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreferenceCompositeDescriptor;
+import org.eclipse.cdt.codan.core.param.ListProblemPreference;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.FileFieldEditor;
+import org.eclipse.jface.preference.ListEditor;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * Composite to show problem preferences
+ *
+ */
+public class ParametersComposite extends Composite {
+ private FieldEditorPreferencePage page;
+ private IProblem problem;
+ private PreferenceStore prefStore;
+
+ /**
+ * @param parent
+ * @param problem
+ * @param style
+ */
+ public ParametersComposite(Composite parent, final IProblem problem) {
+ super(parent, SWT.NONE);
+ if (problem == null)
+ throw new NullPointerException();
+ this.setLayout(new GridLayout(2, false));
+ this.problem = problem;
+ this.prefStore = new PreferenceStore();
+ page = new FieldEditorPreferencePage() {
+ @Override
+ protected void createFieldEditors() {
+ noDefaultAndApplyButton();
+ IProblemPreference pref = problem.getPreference();
+ createFieldEditorsForParameters(pref);
+ }
+
+ /**
+ * @param info
+ */
+ private void createFieldEditorsForParameters(
+ final IProblemPreference info) {
+ if (info == null)
+ return;
+ if (info.getKey() == FileScopeProblemPreference.KEY)
+ return; // skip the scope
+ switch (info.getType()) {
+ case TYPE_STRING: {
+ StringFieldEditor fe = new StringFieldEditor(
+ info.getQualifiedKey(), info.getLabel(),
+ getFieldEditorParent());
+ addField(fe);
+ break;
+ }
+ case TYPE_BOOLEAN: {
+ BooleanFieldEditor fe = new BooleanFieldEditor(
+ info.getQualifiedKey(), info.getLabel(),
+ getFieldEditorParent());
+ addField(fe);
+ break;
+ }
+ case TYPE_LIST:
+ ListEditor le = new ListEditor(info.getQualifiedKey(),
+ info.getLabel(), getFieldEditorParent()) {
+ @Override
+ protected String[] parseString(String stringList) {
+ ListProblemPreference list = (ListProblemPreference) info;
+ IProblemPreference[] childDescriptors = list
+ .getChildDescriptors();
+ if (childDescriptors.length == 0)
+ return new String[0];
+ String res[] = new String[childDescriptors.length];
+ for (int i = 0; i < childDescriptors.length; i++) {
+ IProblemPreference item = childDescriptors[i];
+ res[i] = String.valueOf(item.getValue());
+ }
+ return res;
+ }
+
+ @Override
+ protected String getNewInputObject() {
+ ListProblemPreference list = (ListProblemPreference) info;
+ String label = list.getChildDescriptor()
+ .getLabel();
+ InputDialog dialog = new InputDialog(
+ getShell(),
+ CodanUIMessages.ParametersComposite_NewValue,
+ label, "", null); //$NON-NLS-1$
+ if (dialog.open() == Window.OK) {
+ return dialog.getValue();
+ }
+ return null;
+ }
+
+ @Override
+ protected String createList(String[] items) {
+ ListProblemPreference list = (ListProblemPreference) info
+ .clone();
+ list.clear();
+ for (int i = 0; i < items.length; i++) {
+ String val = items[i];
+ list.addChildValue(val);
+ }
+ return list.exportValue();
+ }
+ };
+ addField(le);
+ break;
+ case TYPE_MAP:
+ IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) info)
+ .getChildDescriptors();
+ for (int i = 0; i < childrenDescriptor.length; i++) {
+ IProblemPreference desc = childrenDescriptor[i];
+ createFieldEditorsForParameters(desc);
+ }
+ break;
+ case TYPE_CUSTOM: {
+ StringFieldEditor fe = new StringFieldEditor(
+ info.getQualifiedKey(), info.getLabel(),
+ getFieldEditorParent());
+ addField(fe);
+ break;
+ }
+ case TYPE_FILE: {
+ FileFieldEditor fe = new FileFieldEditor(
+ info.getQualifiedKey(), info.getLabel(),
+ getFieldEditorParent());
+ addField(fe);
+ break;
+ }
+ default:
+ throw new UnsupportedOperationException(info.getType()
+ .toString());
+ }
+ }
+ };
+ IProblemPreference info = problem.getPreference();
+ if (info == null) {
+ Label label = new Label(this, 0);
+ label.setText(CodanUIMessages.ParametersComposite_None);
+ } else {
+ initPrefStore(info);
+ }
+ page.setPreferenceStore(prefStore);
+ page.createControl(parent);
+ page.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+
+ public void save(IProblemWorkingCopy problem) {
+ page.performOk();
+ savePrefStore(problem.getPreference());
+ }
+
+ private void savePrefStore(IProblemPreference desc) {
+ if (desc == null)
+ return;
+ String key = desc.getQualifiedKey();
+ switch (desc.getType()) {
+ case TYPE_STRING:
+ desc.setValue(prefStore.getString(key));
+ break;
+ case TYPE_BOOLEAN:
+ desc.setValue(prefStore.getBoolean(key));
+ break;
+ case TYPE_INTEGER:
+ desc.setValue(prefStore.getInt(key));
+ break;
+ case TYPE_FILE:
+ desc.setValue(new File(prefStore.getString(key)));
+ break;
+ case TYPE_LIST:
+ desc.importValue(prefStore.getString(key));
+ break;
+ case TYPE_CUSTOM:
+ desc.importValue(prefStore.getString(key));
+ break;
+ case TYPE_MAP:
+ IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) desc)
+ .getChildDescriptors();
+ for (int i = 0; i < childrenDescriptor.length; i++) {
+ IProblemPreference chi = childrenDescriptor[i];
+ savePrefStore(chi);
+ }
+ break;
+ default:
+ throw new UnsupportedOperationException(desc.getType()
+ .toString());
+ }
+ }
+
+ private void initPrefStore(IProblemPreference desc) {
+ if (desc == null)
+ return;
+ String key = desc.getQualifiedKey();
+ switch (desc.getType()) {
+ case TYPE_STRING:
+ prefStore.setValue(key, (String) desc.getValue());
+ break;
+ case TYPE_BOOLEAN:
+ prefStore.setValue(key, (Boolean) desc.getValue());
+ break;
+ case TYPE_INTEGER:
+ prefStore.setValue(key, (Integer) desc.getValue());
+ break;
+ case TYPE_FILE:
+ prefStore.setValue(key, ((File) desc.getValue()).getPath());
+ break;
+ case TYPE_LIST:
+ prefStore.setValue(key, desc.exportValue());
+ break;
+ case TYPE_CUSTOM:
+ prefStore.setValue(key, desc.exportValue());
+ break;
+ case TYPE_MAP:
+ IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) desc)
+ .getChildDescriptors();
+ for (int i = 0; i < childrenDescriptor.length; i++) {
+ IProblemPreference chi = childrenDescriptor[i];
+ initPrefStore(chi);
+ }
+ break;
+ default:
+ throw new UnsupportedOperationException(desc.getType()
+ .toString());
+ }
+ }
+
+ /**
+ * @return the problem
+ */
+ public IProblem getProblem() {
+ return problem;
+ }
+}