Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reworked preferences stuff to use the new API.

The use of the old API resulted in many compilation warnings
that distracted from the real problems.
  • Loading branch information...
commit dd7fb2e19f14314115ec2cf34bce64a5bee5e4bd 1 parent 83ed354
@ttencate authored
Showing with 446 additions and 298 deletions.
  1. +3 −3 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/halamo/HaskellModelManager_PDETest.java
  2. +7 −6 ...sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/halamo/WorkspaceChangeMonitor_PDETest.java
  3. +5 −3 ...ipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/internal/project/HaskellProject_PDETestCase.java
  4. +9 −3 ...skell.core.test/src/net/sf/eclipsefp/haskell/core/internal/project/ProjectCreationOperationPDETestCase.java
  5. +10 −1 ...sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/internal/project/ProjectModel_PDETest.java
  6. +6 −6 ...askell.core.test/src/net/sf/eclipsefp/haskell/core/internal/project/TestHaskellProjectMetaTest_PDETest.java
  7. +10 −12 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/internal/util/TestHaskellProject.java
  8. +9 −13 ...fp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/project/HaskellProjectCreationOperation_PDETest.java
  9. +70 −0 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/test/TestCaseWithPreferences.java
  10. +9 −2 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/test/TestCaseWithProject.java
  11. +41 −0 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/test/TestScope.java
  12. +1 −2  net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/HaskellCorePlugin.java
  13. +12 −16 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/compiler/CompilerManager.java
  14. +8 −14 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/preferences/CorePreferenceInitializer.java
  15. +12 −23 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/project/HaskellProjectCreationOperation.java
  16. +13 −4 ...L/java/test/net/sf/eclipsefp/haskell/debug/ui/internal/launch/ghci/GhciLaunchOperationDelegate_PDETest.java
  17. +3 −4 ...i/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/ui/internal/launch/ghci/GhciLaunchOperationDelegate.java
  18. +9 −0 net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/GhcCompilerPlugin.java
  19. +6 −8 net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/CompilerParams.java
  20. +39 −38 ...fp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/preferences/PreferenceInitializer.java
  21. +7 −1 ...clipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/ui/preferences/GhcPreferencePage.java
  22. +62 −66 net.sf.eclipsefp.haskell.haddock/src/net/sf/eclipsefp/haskell/haddock/core/HaddockInfo.java
  23. +6 −8 ....eclipsefp.haskell.haddock/src/net/sf/eclipsefp/haskell/haddock/core/preferences/PreferenceInitializer.java
  24. +18 −11 net.sf.eclipsefp.haskell.hugs/src/net/sf/eclipsefp/haskell/hugs/HugsPlugin.java
  25. +7 −11 net.sf.eclipsefp.haskell.hugs/src/net/sf/eclipsefp/haskell/hugs/core/Util.java
  26. +9 −11 net.sf.eclipsefp.haskell.hugs/src/net/sf/eclipsefp/haskell/hugs/core/preferences/PreferenceInitializer.java
  27. +7 −2 net.sf.eclipsefp.haskell.hugs/src/net/sf/eclipsefp/haskell/hugs/ui/preferences/HugsPreferencePage.java
  28. +7 −5 .../sf/eclipsefp/haskell/ui/internal/editors/haskell/codeassist/WorkbenchHaskellCompletionContext_PDETest.java
  29. +6 −1 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/preferences/NewHaskellProjectPP.java
  30. +7 −1 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/preferences/editor/HaskellEditorPP.java
  31. +18 −14 ...efp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/preferences/hsimpls/InstalledImplementationsPP.java
  32. +1 −1  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/scion/ScionManager.java
  33. +9 −8 ...p.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/projectexplorer/HaskellResourceExtensionCP.java
View
6 ...sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/halamo/HaskellModelManager_PDETest.java
@@ -1,14 +1,14 @@
package net.sf.eclipsefp.haskell.core.halamo;
import static org.easymock.EasyMock.createMock;
-import junit.framework.TestCase;
import net.sf.eclipsefp.haskell.core.internal.util.TestHaskellProject;
+import net.sf.eclipsefp.haskell.core.test.TestCaseWithPreferences;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-public class HaskellModelManager_PDETest extends TestCase {
+public class HaskellModelManager_PDETest extends TestCaseWithPreferences {
public void testCreatesModelsForNewProjects() {
IWorkspace workspace = createMock(IWorkspace.class);
@@ -25,7 +25,7 @@ public void testCreatesModelsForNewProjects() {
}
public void testFetchesModelsForExistingProjects() throws CoreException {
- TestHaskellProject project = new TestHaskellProject("factorial");
+ TestHaskellProject project = new TestHaskellProject("factorial", getCorePrefs());
try {
project.createSourceFile("Factorial.hs", "module Factorial where\n" +
"\n" +
View
13 ...eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/halamo/WorkspaceChangeMonitor_PDETest.java
@@ -8,8 +8,8 @@
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.resetToDefault;
import static org.easymock.EasyMock.verify;
-import junit.framework.TestCase;
import net.sf.eclipsefp.haskell.core.internal.util.TestHaskellProject;
+import net.sf.eclipsefp.haskell.core.test.TestCaseWithPreferences;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
@@ -17,7 +17,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-public class WorkspaceChangeMonitor_PDETest extends TestCase {
+public class WorkspaceChangeMonitor_PDETest extends TestCaseWithPreferences {
private IProjectChangeMonitorFactory fFactory;
private WorkspaceChangeMonitor fMonitor;
@@ -30,7 +30,7 @@ public void testCreatesChangeMonitorWhenProjectIsCreated()
andReturn( createMock(IResourceChangeListener.class) );
replay(factory);
- TestHaskellProject prj = new TestHaskellProject("createsChangeMonitorProject");
+ TestHaskellProject prj = new TestHaskellProject("createsChangeMonitorProject", getCorePrefs());
prj.destroy();
verify(factory);
@@ -45,8 +45,8 @@ public void testDelegatesProjectEventsToCorrespondingMonitor() throws CoreExcept
andReturn(sndMonitor);
replay(getFactory());
- TestHaskellProject fstPrj = new TestHaskellProject("first-project");
- TestHaskellProject sndPrj = new TestHaskellProject("second-project");
+ TestHaskellProject fstPrj = new TestHaskellProject("first-project", getCorePrefs());
+ TestHaskellProject sndPrj = new TestHaskellProject("second-project", getCorePrefs());
try {
fstMonitor.resourceChanged((IResourceChangeEvent) anyObject());
@@ -62,7 +62,7 @@ public void testDelegatesProjectEventsToCorrespondingMonitor() throws CoreExcept
public void testCreatesProjectMonitorsForLoadedWorkspace()
throws CoreException {
- TestHaskellProject prj = new TestHaskellProject("myproject");
+ TestHaskellProject prj = new TestHaskellProject("myproject", getCorePrefs());
IProjectChangeMonitorFactory factory =
createMock(IProjectChangeMonitorFactory.class);
@@ -110,6 +110,7 @@ protected void tearDown() throws Exception {
if (fMonitor != null) {
getWorkspace().removeResourceChangeListener(fMonitor);
}
+ super.tearDown();
}
}
View
8 ...efp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/internal/project/HaskellProject_PDETestCase.java
@@ -3,8 +3,8 @@
// version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
package net.sf.eclipsefp.haskell.core.internal.project;
-import junit.framework.TestCase;
import net.sf.eclipsefp.haskell.core.internal.util.TestHaskellProject;
+import net.sf.eclipsefp.haskell.core.test.TestCaseWithPreferences;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@@ -16,7 +16,7 @@
*
* @author Leif Frenzel
*/
-public abstract class HaskellProject_PDETestCase extends TestCase {
+public abstract class HaskellProject_PDETestCase extends TestCaseWithPreferences {
private TestHaskellProject fProject;
@@ -26,7 +26,8 @@ protected IProject getProject() {
@Override
protected final void setUp() throws Exception {
- fProject = new TestHaskellProject("TestProject-1");
+ super.setUp();
+ fProject = new TestHaskellProject("TestProject-1", getCorePrefs());
setUpMore();
}
@@ -52,6 +53,7 @@ protected void doTearDown() throws Exception {
protected final void tearDown() throws Exception {
doTearDown();
fProject.destroy();
+ super.tearDown();
}
protected IFile createSourceFile(final String contents, final String name)
View
12 ...ll.core.test/src/net/sf/eclipsefp/haskell/core/internal/project/ProjectCreationOperationPDETestCase.java
@@ -1,7 +1,7 @@
package net.sf.eclipsefp.haskell.core.internal.project;
import java.io.IOException;
-import junit.framework.TestCase;
+import net.sf.eclipsefp.haskell.core.test.TestCaseWithPreferences;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -10,15 +10,20 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-public class ProjectCreationOperationPDETestCase extends TestCase {
+public class ProjectCreationOperationPDETestCase extends TestCaseWithPreferences {
protected static final String PROJECT_NAME = "hello.haskell.world";
private IWorkspaceRoot fWorkspaceRoot;
private ProjectCreationOperation fOperation;
+ public ProjectCreationOperationPDETestCase() {
+ super();
+ }
+
@Override
- protected void setUp() {
+ protected void setUp() throws Exception {
+ super.setUp();
fWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
fOperation = createOperation();
fOperation.setProjectName(PROJECT_NAME);
@@ -60,6 +65,7 @@ protected void assertSameLocation(final String expected, final String actual) th
@Override
protected void tearDown() throws Exception {
deleteCreatedProject();
+ super.tearDown();
}
private void deleteCreatedProject() throws CoreException {
View
11 ...eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/internal/project/ProjectModel_PDETest.java
@@ -18,10 +18,19 @@
*/
public class ProjectModel_PDETest extends TestCaseWithProject {
+ public ProjectModel_PDETest() {
+ super();
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
@Override
protected void tearDown() throws Exception {
- super.tearDown();
HaskellProjectManager.clear();
+ super.tearDown();
}
View
12 ...ell.core.test/src/net/sf/eclipsefp/haskell/core/internal/project/TestHaskellProjectMetaTest_PDETest.java
@@ -3,22 +3,22 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import junit.framework.TestCase;
import net.sf.eclipsefp.haskell.core.compiler.DefaultHaskellCompiler;
import net.sf.eclipsefp.haskell.core.internal.util.TestHaskellProject;
import net.sf.eclipsefp.haskell.core.project.HaskellNature;
import net.sf.eclipsefp.haskell.core.project.HaskellProjectManager;
import net.sf.eclipsefp.haskell.core.project.IHaskellProject;
+import net.sf.eclipsefp.haskell.core.test.TestCaseWithPreferences;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-public class TestHaskellProjectMetaTest_PDETest extends TestCase {
+public class TestHaskellProjectMetaTest_PDETest extends TestCaseWithPreferences {
public void testConstructorCreatesProject() throws CoreException {
- new TestHaskellProject("testing-project");
+ new TestHaskellProject("testing-project", getCorePrefs());
IProject project = getProject("testing-project");
assertNotNull(project);
@@ -28,7 +28,7 @@ public void testConstructorCreatesProject() throws CoreException {
}
public void testCreatingSourceFiles() throws CoreException, IOException {
- TestHaskellProject project = new TestHaskellProject("another-project");
+ TestHaskellProject project = new TestHaskellProject("another-project", getCorePrefs());
project.createSourceFile("MyFile.txt", "These are the file contents\n");
@@ -40,7 +40,7 @@ public void testCreatingSourceFiles() throws CoreException, IOException {
}
public void testDestroyProject() throws CoreException {
- TestHaskellProject project = new TestHaskellProject("other-project");
+ TestHaskellProject project = new TestHaskellProject("other-project", getCorePrefs());
IProject underlyingProject = getProject("other-project");
assertNotNull(underlyingProject);
@@ -53,7 +53,7 @@ public void testDestroyProject() throws CoreException {
}
public void testUsesDefaultCompiler() throws CoreException {
- TestHaskellProject project = new TestHaskellProject("yet-another-project");
+ TestHaskellProject project = new TestHaskellProject("yet-another-project", getCorePrefs());
IHaskellProject hsprj = HaskellProjectManager.get(getProject("yet-another-project"));
assertEquals(DefaultHaskellCompiler.class, hsprj.getCompiler().getClass());
View
22 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/internal/util/TestHaskellProject.java
@@ -10,17 +10,17 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
public class TestHaskellProject implements ICorePreferenceNames {
private IProject fUnderlyingProject;
private IFolder fSourceFolder;
- public TestHaskellProject(final String projectName) throws CoreException {
- ProjectCreationOperation op = new HaskellProjectCreationOperation(
- preferences());
+ public TestHaskellProject(final String projectName, final IEclipsePreferences corePrefs) throws CoreException {
+ setPreferences(corePrefs);
+ ProjectCreationOperation op = new HaskellProjectCreationOperation();
op.setProjectName(projectName);
try {
op.run(new NullProgressMonitor());
@@ -32,14 +32,12 @@ public TestHaskellProject(final String projectName) throws CoreException {
}
}
- private Preferences preferences() {
- Preferences preferences = new Preferences();
- preferences.setValue( SELECTED_COMPILER, "null" );
- preferences.setValue( FOLDERS_SRC, "src" );
- preferences.setValue( FOLDERS_OUT, "out" );
- preferences.setValue( TARGET_BINARY, "bin/theResult" );
- preferences.setValue( FOLDERS_IN_NEW_PROJECT, true );
- return preferences;
+ private void setPreferences(final IEclipsePreferences corePrefs) {
+ corePrefs.put( SELECTED_COMPILER, "null" );
+ corePrefs.put( FOLDERS_SRC, "src" );
+ corePrefs.put( FOLDERS_OUT, "out" );
+ corePrefs.put( TARGET_BINARY, "bin/theResult" );
+ corePrefs.putBoolean( FOLDERS_IN_NEW_PROJECT, true );
}
public IFile createSourceFile(final String fileName, final String contents) throws CoreException {
View
22 ...haskell.core.test/src/net/sf/eclipsefp/haskell/core/project/HaskellProjectCreationOperation_PDETest.java
@@ -13,19 +13,15 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Preferences;
public class HaskellProjectCreationOperation_PDETest extends
ProjectCreationOperationPDETestCase {
- private Preferences fStore;
-
@Override
protected ProjectCreationOperation createOperation() {
- fStore = new Preferences();
- fStore.setValue( ICorePreferenceNames.FOLDERS_IN_NEW_PROJECT, true );
+ getCorePrefs().putBoolean( ICorePreferenceNames.FOLDERS_IN_NEW_PROJECT, true );
HaskellProjectCreationOperation result
- = new HaskellProjectCreationOperation( fStore );
+ = new HaskellProjectCreationOperation( );
result.setExtraOperation( new ProjectModelFilesOp() );
return result;
}
@@ -40,8 +36,8 @@ public void testAddsHaskellNature() throws InvocationTargetException,
public void testCreatesDirectoriesFromPreferences()
throws InvocationTargetException, InterruptedException {
- fStore.setValue( ICorePreferenceNames.FOLDERS_SRC, "customSrc" );
- fStore.setValue( ICorePreferenceNames.FOLDERS_OUT, "customOut" );
+ getCorePrefs().put( ICorePreferenceNames.FOLDERS_SRC, "customSrc" );
+ getCorePrefs().put( ICorePreferenceNames.FOLDERS_OUT, "customOut" );
runOperation();
IProject prj = getWorkspaceRoot().getProject( PROJECT_NAME );
@@ -62,10 +58,10 @@ public void testCreatesDescriptorFile() throws InvocationTargetException,
}
public void testSetsUpProjectFoldersFromPreferences() throws Exception {
- fStore.setValue( ICorePreferenceNames.FOLDERS_SRC, "mySrc" );
- fStore.setValue( ICorePreferenceNames.FOLDERS_OUT, "myOut" );
- fStore.setValue( ICorePreferenceNames.TARGET_BINARY, "myBinary" );
- fStore.setValue( ICorePreferenceNames.SELECTED_COMPILER, "null" );
+ getCorePrefs().put( ICorePreferenceNames.FOLDERS_SRC, "mySrc" );
+ getCorePrefs().put( ICorePreferenceNames.FOLDERS_OUT, "myOut" );
+ getCorePrefs().put( ICorePreferenceNames.TARGET_BINARY, "myBinary" );
+ getCorePrefs().put( ICorePreferenceNames.SELECTED_COMPILER, "null" );
runOperation();
IProject prj = getWorkspaceRoot().getProject( PROJECT_NAME );
@@ -77,7 +73,7 @@ public void testSetsUpProjectFoldersFromPreferences() throws Exception {
}
public void testDoNotCreateFoldersWhenPreferenceDisabled() throws Exception {
- fStore.setValue( ICorePreferenceNames.FOLDERS_IN_NEW_PROJECT, false );
+ getCorePrefs().putBoolean( ICorePreferenceNames.FOLDERS_IN_NEW_PROJECT, false );
runOperation();
View
70 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/test/TestCaseWithPreferences.java
@@ -0,0 +1,70 @@
+package net.sf.eclipsefp.haskell.core.test;
+
+import java.util.ArrayList;
+import junit.framework.TestCase;
+import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+
+/**
+ * Test case that uses preferences.
+ * It adds a specialized scope for them, and changes the default lookup order.
+ *
+ * @author Thomas ten Cate
+ */
+public class TestCaseWithPreferences extends TestCase {
+
+ private final ArrayList<String> fQualifiers = new ArrayList<String>();
+ private IScopeContext fPrefsScope;
+
+ public TestCaseWithPreferences() {
+ addQualifier( HaskellCorePlugin.getPluginId() );
+ }
+
+ /**
+ * Adds a plug-in to the list of plug-ins that should use the test scope for lookups.
+ * This only has an effect before setUp() is called.
+ * Normally, this should be called from the constructor.
+ *
+ * @param qualifier the plug-in ID
+ */
+ protected void addQualifier(final String qualifier) {
+ fQualifiers.add(qualifier);
+ }
+
+ protected IScopeContext getPrefsScope() {
+ return fPrefsScope;
+ }
+
+ public IEclipsePreferences getCorePrefs() {
+ return getPrefsScope().getNode( HaskellCorePlugin.getPluginId() );
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ fPrefsScope = new TestScope();
+ // add TestScope to the preferences lookup order
+ String[] lookupOrder = new String[] {
+ TestScope.SCOPE, ProjectScope.SCOPE, InstanceScope.SCOPE, ConfigurationScope.SCOPE, DefaultScope.SCOPE
+ };
+ for (String qualifier : fQualifiers) {
+ Platform.getPreferencesService().setDefaultLookupOrder( qualifier, null, lookupOrder );
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ for (String qualifier : fQualifiers) {
+ Platform.getPreferencesService().setDefaultLookupOrder( qualifier, null, null );
+ }
+ getPrefsScope().getNode( "" ).removeNode();
+ super.tearDown();
+ }
+
+}
View
11 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/test/TestCaseWithProject.java
@@ -3,7 +3,7 @@
// version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
package net.sf.eclipsefp.haskell.core.test;
-import junit.framework.TestCase;
+import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
import net.sf.eclipsefp.haskell.core.internal.project.ProjectCreationOperation;
import net.sf.eclipsefp.haskell.core.internal.project.ProjectModelFilesOp;
import net.sf.eclipsefp.haskell.core.project.HaskellProjectCreationOperation;
@@ -21,11 +21,15 @@
*
* @author Leif Frenzel
*/
-public class TestCaseWithProject extends TestCase {
+public class TestCaseWithProject extends TestCaseWithPreferences {
protected static final String PROJECT_NAME = "p1";
protected IProject project;
+ public TestCaseWithProject() {
+ addQualifier( HaskellCorePlugin.getPluginId() );
+ }
+
public static void waitForAutoBuild() throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.build( IncrementalProjectBuilder.CLEAN_BUILD, null );
@@ -51,6 +55,8 @@ public static void waitForAutoBuild() throws CoreException {
@Override
protected void setUp() throws Exception {
+ super.setUp();
+
ProjectCreationOperation op = new HaskellProjectCreationOperation();
op.setExtraOperation( new ProjectModelFilesOp() );
op.setProjectName( PROJECT_NAME );
@@ -63,5 +69,6 @@ protected void setUp() throws Exception {
@Override
protected void tearDown() throws Exception {
project.delete( true, null );
+ super.tearDown();
}
}
View
41 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/test/TestScope.java
@@ -0,0 +1,41 @@
+package net.sf.eclipsefp.haskell.core.test;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+
+/**
+ * Scope for preferences used in unit tests.
+ * Based on the code of {@link InstanceScope}.
+ *
+ * @author Thomas ten Cate
+ */
+public class TestScope implements IScopeContext {
+
+ /**
+ * String constant (value of <code>"instance"</code>) used for the
+ * scope name for the instance preference scope.
+ */
+ public static final String SCOPE = "test"; //$NON-NLS-1$
+
+ public IPath getLocation() {
+ // Return null. InstanceScope does this too, and remarks:
+ // The instance location usually corresponds to the state
+ // location of the bundle and we don't know what bundle we are dealing with.
+ return null;
+ }
+
+ public String getName() {
+ return SCOPE;
+ }
+
+ public IEclipsePreferences getNode( final String qualifier ) {
+ if (qualifier == null) {
+ throw new IllegalArgumentException();
+ }
+ return (IEclipsePreferences) Platform.getPreferencesService().getRootNode().node(getName()).node(qualifier);
+ }
+
+}
View
3  net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/HaskellCorePlugin.java
@@ -154,8 +154,7 @@ private void collectCompilerInfo() {
}
String pref = ""; //$NON-NLS-1$
try {
- String name = ICorePreferenceNames.SELECTED_COMPILER;
- pref = getPluginPreferences().getString( name );
+ pref = Platform.getPreferencesService().getString( getPluginId(), ICorePreferenceNames.SELECTED_COMPILER, "null", null ); //$NON-NLS-1$
CompilerManager.getInstance().selectCompiler( pref );
} catch( Exception ex ) {
String msg = "Problem when selecting compiler '" + pref + "'."; //$NON-NLS-1$ //$NON-NLS-2$
View
28 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/compiler/CompilerManager.java
@@ -15,9 +15,10 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
-import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
/**
* <p>
@@ -227,21 +228,16 @@ private ListenableCompilerDecorator getSelectedCompilerDecorator() {
}
private void initHsImplementation() {
- String key = ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION;
- String currentImplName = getPrefs().getString( key );
+ String currentImplName = Platform.getPreferencesService().getString( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION, null, null );
if( currentImplName != null ) {
Map<String, IHsImplementation> impls = loadImpls();
this.currentHsImplementation = impls.get( currentImplName );
}
}
- private Preferences getPrefs() {
- return HaskellCorePlugin.getDefault().getPluginPreferences();
- }
-
private Map<String, IHsImplementation> loadImpls() {
List<IHsImplementation> impls = new ArrayList<IHsImplementation>();
- String xml = getPrefs().getString( ICorePreferenceNames.HS_IMPLEMENTATIONS );
+ String xml = Platform.getPreferencesService().getString( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.HS_IMPLEMENTATIONS, null, null );
HsImplementationPersister.fromXML( xml, impls );
Map<String, IHsImplementation> result = new HashMap<String, IHsImplementation>();
for( IHsImplementation impl: impls ) {
@@ -251,14 +247,14 @@ private Preferences getPrefs() {
}
private void listenForImplPref() {
- getPrefs().addPropertyChangeListener( new IPropertyChangeListener() {
- public void propertyChange( final PropertyChangeEvent event ) {
- String prop = event.getProperty();
- if( ICorePreferenceNames.HS_IMPLEMENTATIONS.equals( prop )
- || ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION.equals( prop ) ) {
+ new InstanceScope().getNode( HaskellCorePlugin.getPluginId() ).addPreferenceChangeListener( new IPreferenceChangeListener() {
+ public void preferenceChange( final PreferenceChangeEvent event ) {
+ String key = event.getKey();
+ if( ICorePreferenceNames.HS_IMPLEMENTATIONS.equals( key )
+ || ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION.equals( key ) ) {
initHsImplementation();
}
}
- } );
+ });
}
}
View
22 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/preferences/CorePreferenceInitializer.java
@@ -2,8 +2,9 @@
package net.sf.eclipsefp.haskell.core.preferences;
import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
/** <p>initializer for the core preferences (declared in the
@@ -20,19 +21,12 @@
@Override
public void initializeDefaultPreferences() {
- Preferences preferences = getPreferences();
- preferences.setDefault( SELECTED_COMPILER, "ghcCompiler" ); //$NON-NLS-1$
- preferences.setDefault( FOLDERS_SRC, "src" ); //$NON-NLS-1$
- preferences.setDefault( FOLDERS_OUT, "out" ); //$NON-NLS-1$
- preferences.setDefault( TARGET_BINARY, "bin/theResult" ); //$NON-NLS-1$
- preferences.setDefault( FOLDERS_IN_NEW_PROJECT, true );
+ IEclipsePreferences coreNode = new DefaultScope().getNode( HaskellCorePlugin.getPluginId() );
+ coreNode.put( SELECTED_COMPILER, "ghcCompiler" ); //$NON-NLS-1$
+ coreNode.put( FOLDERS_SRC, "src" ); //$NON-NLS-1$
+ coreNode.put( FOLDERS_OUT, "out" ); //$NON-NLS-1$
+ coreNode.put( TARGET_BINARY, "bin/theResult" ); //$NON-NLS-1$
+ coreNode.putBoolean( FOLDERS_IN_NEW_PROJECT, true );
}
-
- // helping methods
- //////////////////
-
- private Preferences getPreferences() {
- return HaskellCorePlugin.getDefault().getPluginPreferences();
- }
}
View
35 ...sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/project/HaskellProjectCreationOperation.java
@@ -4,18 +4,13 @@
import net.sf.eclipsefp.haskell.core.internal.project.DescriptorFileInfo;
import net.sf.eclipsefp.haskell.core.internal.project.ProjectCreationOperation;
import net.sf.eclipsefp.haskell.core.preferences.ICorePreferenceNames;
-import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
public class HaskellProjectCreationOperation extends ProjectCreationOperation {
- private final Preferences fPreferences;
-
public HaskellProjectCreationOperation() {
- this( HaskellCorePlugin.getDefault().getPluginPreferences() );
- }
-
- public HaskellProjectCreationOperation( final Preferences prefs ) {
- fPreferences = prefs;
+ super();
}
@Override
@@ -28,8 +23,9 @@ public HaskellProjectCreationOperation( final Preferences prefs ) {
if (! createFolders() ) {
return new String[0];
}
- String sourcePath = getPreference(ICorePreferenceNames.FOLDERS_SRC);
- String outputPath = getPreference(ICorePreferenceNames.FOLDERS_OUT);
+ IPreferencesService service = Platform.getPreferencesService();
+ String sourcePath = service.getString( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.FOLDERS_SRC, null, null );
+ String outputPath = service.getString( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.FOLDERS_OUT, null, null );
return new String[] { sourcePath, outputPath };
}
@@ -44,23 +40,16 @@ private String createDescriptorContent() {
if (! createFolders() ) {
return ""; //$NON-NLS-1$
}
+ IPreferencesService service = Platform.getPreferencesService();
return HaskellProjectManager.createDescriptorContent(
- getPreference(ICorePreferenceNames.FOLDERS_SRC),
- getPreference(ICorePreferenceNames.FOLDERS_OUT),
- getPreference(ICorePreferenceNames.TARGET_BINARY),
- getPreference(ICorePreferenceNames.SELECTED_COMPILER));
+ service.getString( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.FOLDERS_SRC, null, null ),
+ service.getString( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.FOLDERS_OUT, null, null ),
+ service.getString( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.TARGET_BINARY, null, null ),
+ service.getString( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.SELECTED_COMPILER, null, null ));
}
private boolean createFolders() {
- String prefKey = ICorePreferenceNames.FOLDERS_IN_NEW_PROJECT;
- return getStore().getBoolean(prefKey);
+ return Platform.getPreferencesService().getBoolean( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.FOLDERS_IN_NEW_PROJECT, false, null );
}
- private String getPreference(final String name) {
- return getStore().getString(name);
- }
-
- private Preferences getStore() {
- return fPreferences;
- }
}
View
17 ...ava/test/net/sf/eclipsefp/haskell/debug/ui/internal/launch/ghci/GhciLaunchOperationDelegate_PDETest.java
@@ -12,7 +12,8 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.osgi.service.prefs.BackingStoreException;
/** <p>test cases for the launch operation delegate.</p>
*
@@ -20,6 +21,10 @@
*/
public class GhciLaunchOperationDelegate_PDETest extends TestCaseWithProject {
+ public GhciLaunchOperationDelegate_PDETest() {
+ addQualifier( GhcCompilerPlugin.getPluginId() );
+ }
+
public void testAddSourceFolders_single() throws Exception {
// what we expect to show up in the command lines
String locOfSrc = putInQuotes( project.getLocation().append( "src" ) );
@@ -95,8 +100,12 @@ private boolean contains( final String candidate, final String[] args ) {
}
private void setPref( final boolean value ) {
- Preferences prefs = GhcCompilerPlugin.getDefault().getPluginPreferences();
- prefs.setValue( IGhcPreferenceNames.GHCI_SOURCE_FOLDERS, value );
- GhcCompilerPlugin.getDefault().savePluginPreferences();
+ IEclipsePreferences node = getPrefsScope().getNode( GhcCompilerPlugin.getPluginId() );
+ node.putBoolean( IGhcPreferenceNames.GHCI_SOURCE_FOLDERS, value );
+ try {
+ node.flush();
+ } catch( BackingStoreException ex ) {
+ GhcCompilerPlugin.log( "Failed to store preferences", ex );
+ }
}
}
View
7 ...NTERNAL/java/src/net/sf/eclipsefp/haskell/debug/ui/internal/launch/ghci/GhciLaunchOperationDelegate.java
@@ -22,7 +22,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Platform;
/** <p>implements a delegate for launching GHCi.</p>
*
@@ -104,9 +104,8 @@ private void collectImportDirsRec(
}
}
- private boolean isPrefSet( final String name ) {
- Preferences prefs = GhcCompilerPlugin.getDefault().getPluginPreferences();
- return prefs.getBoolean( name );
+ private boolean isPrefSet( final String key ) {
+ return Platform.getPreferencesService().getBoolean( GhcCompilerPlugin.getPluginId(), key, false, null );
}
private void addAll( final List<String> cmdLine, final IFile[] selectedFiles ) {
View
9 net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/GhcCompilerPlugin.java
@@ -58,6 +58,15 @@ public static void log( final String message, final Throwable throwable ) {
getDefault().getLog().log( status );
}
+ public static void log( final Throwable throwable ) {
+ Status status = new Status( IStatus.ERROR,
+ getPluginId(),
+ IStatus.OK,
+ throwable.getMessage(),
+ throwable );
+ getDefault().getLog().log( status );
+ }
+
public static void log( final String message, final int severity, final Throwable throwable ) {
Status status = new Status( severity,
getPluginId(),
View
14 net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/CompilerParams.java
@@ -5,7 +5,7 @@
import java.util.List;
import net.sf.eclipsefp.haskell.ghccompiler.GhcCompilerPlugin;
import net.sf.eclipsefp.haskell.ghccompiler.core.preferences.IGhcPreferenceNames;
-import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Platform;
/** <p>a helper that constructs compiler parameters from the current settings
* in the preferences.</p>
@@ -14,10 +14,8 @@
*/
public class CompilerParams implements IGhcPreferenceNames, IGhcParameters {
- private final Preferences preferences;
-
public CompilerParams() {
- preferences = GhcCompilerPlugin.getDefault().getPluginPreferences();
+ super();
}
public List<String> construct() {
@@ -74,8 +72,8 @@ private void addMoreOptimizationParams( final List<String> result ) {
}
private void addExtraOptions( final List<String> list ) {
- if( preferences.getBoolean( USE_EXTRA_OPTIONS ) ) {
- String extras = preferences.getString( EXTRA_OPTIONS );
+ if( Platform.getPreferencesService().getBoolean( GhcCompilerPlugin.getPluginId(), USE_EXTRA_OPTIONS, false, null ) ) {
+ String extras = Platform.getPreferencesService().getString( GhcCompilerPlugin.getPluginId(), EXTRA_OPTIONS, null, null );
if( extras != null && !extras.trim().equals( "" ) ) { //$NON-NLS-1$
list.add( extras );
}
@@ -83,14 +81,14 @@ private void addExtraOptions( final List<String> list ) {
}
private void addBooleanParam( final String key, final List<String> list ) {
- boolean value = preferences.getBoolean( key );
+ boolean value = Platform.getPreferencesService().getBoolean( GhcCompilerPlugin.getPluginId(), key, false, null );
if( value ) {
list.add( key );
}
}
private void addOptimizationLevel( final List<String> list ) {
- int level = preferences.getInt( OPTIMIZATION_LEVEL );
+ int level = Platform.getPreferencesService().getInt( GhcCompilerPlugin.getPluginId(), OPTIMIZATION_LEVEL, 0, null );
if( level > -1 ) {
String optLevel = "-O" + String.valueOf( level ); //$NON-NLS-1$
list.add( optLevel );
View
77 ...haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/preferences/PreferenceInitializer.java
@@ -3,8 +3,9 @@
import net.sf.eclipsefp.haskell.ghccompiler.GhcCompilerPlugin;
import net.sf.eclipsefp.haskell.ghccompiler.core.IGhcParameters;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
/** <p>initializer for the GHC compiler preferences (declared in the
* <code>plugin.xml</code>).</p>
@@ -20,7 +21,7 @@
@Override
public void initializeDefaultPreferences() {
- Preferences prefs = GhcCompilerPlugin.getDefault().getPluginPreferences();
+ IEclipsePreferences prefs = new DefaultScope().getNode( GhcCompilerPlugin.getPluginId() );
initializeDefaultValues( prefs );
}
@@ -28,53 +29,53 @@ public void initializeDefaultPreferences() {
// helping methods
//////////////////
- private void initializeDefaultValues( final Preferences prefs ) {
- prefs.setDefault( EXTRA_OPTIONS, "" ); //$NON-NLS-1$
- prefs.setDefault( USE_EXTRA_OPTIONS, false );
- prefs.setDefault( OPTIMIZATION_LEVEL, -1 );
- prefs.setDefault( GHCI_USES_GHC_OPTIONS, false );
- prefs.setDefault( GHCI_SOURCE_FOLDERS, true );
+ private void initializeDefaultValues( final IEclipsePreferences prefs ) {
+ prefs.put( EXTRA_OPTIONS, "" ); //$NON-NLS-1$
+ prefs.putBoolean( USE_EXTRA_OPTIONS, false );
+ prefs.putInt( OPTIMIZATION_LEVEL, -1 );
+ prefs.putBoolean( GHCI_USES_GHC_OPTIONS, false );
+ prefs.putBoolean( GHCI_SOURCE_FOLDERS, true );
initializeLanguageDefaults( prefs );
initializeOptimizationDefaults( prefs );
initializeMoreOptimizationDefaults( prefs );
}
- private void initializeLanguageDefaults( final Preferences prefs ) {
+ private void initializeLanguageDefaults( final IEclipsePreferences prefs ) {
// boolean preferences use the parameter as key
- prefs.setDefault( LANG_GLASGOW_EXTS, false );
- prefs.setDefault( LANG_FI, false );
- prefs.setDefault( LANG_FFI, false );
- prefs.setDefault( LANG_WITH, false );
- prefs.setDefault( LANG_NO_MONOMORPHISM_RESTRICTION, false );
- prefs.setDefault( LANG_ALLOW_OVERLAPPING_INSTANCES, false );
- prefs.setDefault( LANG_ALLOW_UNDECIDABLE_INSTANCES, false );
- prefs.setDefault( LANG_ALLOW_INCOHERENT_INSTANCES, false );
- prefs.setDefault( LANG_GENERICS, false );
- prefs.setDefault( LANG_NO_IMPLICIT_PRELUDE, false );
+ prefs.putBoolean( LANG_GLASGOW_EXTS, false );
+ prefs.putBoolean( LANG_FI, false );
+ prefs.putBoolean( LANG_FFI, false );
+ prefs.putBoolean( LANG_WITH, false );
+ prefs.putBoolean( LANG_NO_MONOMORPHISM_RESTRICTION, false );
+ prefs.putBoolean( LANG_ALLOW_OVERLAPPING_INSTANCES, false );
+ prefs.putBoolean( LANG_ALLOW_UNDECIDABLE_INSTANCES, false );
+ prefs.putBoolean( LANG_ALLOW_INCOHERENT_INSTANCES, false );
+ prefs.putBoolean( LANG_GENERICS, false );
+ prefs.putBoolean( LANG_NO_IMPLICIT_PRELUDE, false );
}
- private void initializeOptimizationDefaults( final Preferences prefs ) {
+ private void initializeOptimizationDefaults( final IEclipsePreferences prefs ) {
// boolean preferences use the parameter as key
- prefs.setDefault( OPT_EXCESS_PRECISION, false );
- prefs.setDefault( OPT_IGNORE_ASSERTS, false );
- prefs.setDefault( OPT_NO_STRICTNESS, false );
- prefs.setDefault( OPT_NO_CPR, false );
- prefs.setDefault( OPT_UNBOX_STRICT_FIELDS, false );
+ prefs.putBoolean( OPT_EXCESS_PRECISION, false );
+ prefs.putBoolean( OPT_IGNORE_ASSERTS, false );
+ prefs.putBoolean( OPT_NO_STRICTNESS, false );
+ prefs.putBoolean( OPT_NO_CPR, false );
+ prefs.putBoolean( OPT_UNBOX_STRICT_FIELDS, false );
}
- private void initializeMoreOptimizationDefaults( final Preferences prefs ) {
+ private void initializeMoreOptimizationDefaults( final IEclipsePreferences prefs ) {
// boolean preferences use the parameter as key
- prefs.setDefault( OPT_CASE_MERGE, false );
- prefs.setDefault( OPT_DICTS_STRICT, false );
- prefs.setDefault( OPT_DO_ETA_REDUCTION, false );
- prefs.setDefault( OPT_DO_LAMBDA_ETA_EXPANSION, false );
- prefs.setDefault( OPT_FOLDR_BUILD_ON, false );
- prefs.setDefault( OPT_IGNORE_INTERFACE_PRAGMAS, false );
- prefs.setDefault( OPT_LET_NO_ESCAPE, false );
- prefs.setDefault( OPT_OMIT_INTERFACE_PRAGMAS, false );
- prefs.setDefault( OPT_NO_CSE, false );
- prefs.setDefault( OPT_NO_PRE_INLINING, false );
- prefs.setDefault( OPT_NUMBERS_STRICT, false );
- prefs.setDefault( OPT_USAGESP, false );
+ prefs.putBoolean( OPT_CASE_MERGE, false );
+ prefs.putBoolean( OPT_DICTS_STRICT, false );
+ prefs.putBoolean( OPT_DO_ETA_REDUCTION, false );
+ prefs.putBoolean( OPT_DO_LAMBDA_ETA_EXPANSION, false );
+ prefs.putBoolean( OPT_FOLDR_BUILD_ON, false );
+ prefs.putBoolean( OPT_IGNORE_INTERFACE_PRAGMAS, false );
+ prefs.putBoolean( OPT_LET_NO_ESCAPE, false );
+ prefs.putBoolean( OPT_OMIT_INTERFACE_PRAGMAS, false );
+ prefs.putBoolean( OPT_NO_CSE, false );
+ prefs.putBoolean( OPT_NO_PRE_INLINING, false );
+ prefs.putBoolean( OPT_NUMBERS_STRICT, false );
+ prefs.putBoolean( OPT_USAGESP, false );
}
}
View
8 ...psefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/ui/preferences/GhcPreferencePage.java
@@ -7,6 +7,7 @@
import net.sf.eclipsefp.haskell.ghccompiler.core.IGhcParameters;
import net.sf.eclipsefp.haskell.ghccompiler.core.preferences.IGhcPreferenceNames;
import net.sf.eclipsefp.haskell.ghccompiler.ui.internal.util.UITexts;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
@@ -17,6 +18,7 @@
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.osgi.service.prefs.BackingStoreException;
/** <p>The preference page for the GHC compiler preferences.</p>
*
@@ -72,7 +74,11 @@ public void dispose() {
@Override
public boolean performOk() {
overlayStore.propagate();
- GhcCompilerPlugin.getDefault().savePluginPreferences();
+ try {
+ new InstanceScope().getNode(GhcCompilerPlugin.getPluginId()).flush();
+ } catch( BackingStoreException ex ) {
+ GhcCompilerPlugin.log( ex );
+ }
return true;
}
View
128 net.sf.eclipsefp.haskell.haddock/src/net/sf/eclipsefp/haskell/haddock/core/HaddockInfo.java
@@ -3,26 +3,24 @@
import java.util.ArrayList;
import java.util.List;
-
import net.sf.eclipsefp.haskell.haddock.HaddockPlugin;
import net.sf.eclipsefp.haskell.haddock.core.preferences.IHaddockPreferenceNames;
-
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Platform;
/** <p>encapsulates all info needed for a particular Haddock run.</p>
- *
+ *
* @author Leif Frenzel
*/
public class HaddockInfo implements IHaddockParameters {
private IProject[] projects;
private InterfaceList readInterfaceFiles = new InterfaceList();
-
- private String[] fileList = new String[ 0 ];
+
+ private String[] fileList = new String[ 0 ];
private String outputDir = "";
private String executable = readExecutableFromPreferences();
-
+
private boolean useTitle = false;
private String title = "";
private boolean useCssFile = false;
@@ -39,8 +37,8 @@
private boolean useContentsURL = false;
private String contentsURL = "";
private boolean generateHTMLHelpFiles = false;
-
-
+
+
/** <p>creates the Haddock command with the information contained in this
* <code>HaddockInfo</code>.</p> */
public List<String> createCommand() {
@@ -49,7 +47,7 @@
list.add( FORMAT_HTML ); // this is the only format currently supported
list.add( OH_DEAR );
list.add( outputDir );
-
+
addParam( useTitle, TITLE, title, list );
addParam( usePrologueFile, PROLOGUE, prologueFile, list );
addParam( useCssFile, CSS_FILE, cssFile, list );
@@ -58,98 +56,98 @@
addReadInterfaces( list );
addParam( useIndexURL, USE_INDEX, indexURL, list );
addParam( useContentsURL, USE_CONTENTS, contentsURL, list );
-
+
// the source files to run Haddock over
for( int i = 0; i < fileList.length; i++ ) {
list.add( fileList[ i ] );
}
return list;
}
-
-
+
+
// attribute setters and getters
////////////////////////////////
-
+
public String getOutputDir() {
return outputDir;
}
-
+
public void setOutputDir( final String outputDir ) {
this.outputDir = ( outputDir == null ) ? "" : outputDir;
}
-
+
public IProject[] getProjects() {
return projects;
}
-
+
public void setProjects( final IProject[] projects ) {
this.projects = ( projects == null ) ? new IProject[ 0 ] : projects;
}
-
+
public String getTitle() {
return title;
}
-
+
public void setTitle( final String title ) {
this.title = ( title == null ) ? "" : title;
}
-
+
public boolean isUseTitle() {
return useTitle;
}
-
+
public void setUseTitle( final boolean useTitle ) {
this.useTitle = useTitle;
}
-
+
public String[] getFileList() {
return fileList;
}
-
+
public void setFileList( final String[] fileList ) {
this.fileList = ( fileList == null ) ? new String [ 0 ] : fileList;
}
-
+
public String getCssFile() {
return cssFile;
}
-
+
public void setCssFile( final String cssFile ) {
this.cssFile = ( cssFile == null ) ? "" : cssFile;
}
-
+
public String getPrologueFile() {
return prologueFile;
}
-
+
public void setPrologueFile( final String prologueFile ) {
this.prologueFile = ( prologueFile == null ) ? "" : prologueFile;
}
-
+
public boolean isUseCssFile() {
return useCssFile;
}
-
+
public void setUseCssFile( final boolean useCSSFile ) {
this.useCssFile = useCSSFile;
}
-
+
public boolean isUsePrologueFile() {
return usePrologueFile;
}
-
+
public void setUsePrologueFile( final boolean usePrologueFile ) {
this.usePrologueFile = usePrologueFile;
}
-
+
public String getExecutable() {
return executable;
}
-
+
public void setExecutable( final String executable ) {
this.executable = ( executable == null ) ? "" : executable;
}
-
+
public String getPackageName() {
return packageName;
}
@@ -157,102 +155,102 @@ public String getPackageName() {
public void setPackageName( final String packageName ) {
this.packageName = ( packageName == null ) ? "" : packageName;
}
-
+
public boolean isUsePackageName() {
return usePackageName;
}
-
+
public void setUsePackageName( final boolean usePackageName ) {
this.usePackageName = usePackageName;
}
-
+
public boolean isDumpInterface() {
return dumpInterface;
}
-
+
public void setDumpInterface( final boolean dumpInterface ) {
this.dumpInterface = dumpInterface;
}
-
+
public String getDumpInterfaceFile() {
return dumpInterfaceFile;
}
-
+
public void setDumpInterfaceFile( final String dumpInterfaceFile ) {
- this.dumpInterfaceFile = ( dumpInterfaceFile == null ) ? ""
+ this.dumpInterfaceFile = ( dumpInterfaceFile == null ) ? ""
: dumpInterfaceFile;
}
-
+
public boolean isReadInterfaces() {
return readInterfaces;
}
-
+
public void setReadInterfaces( final boolean readInterfaces ) {
this.readInterfaces = readInterfaces;
}
-
+
public String getContentsURL() {
return contentsURL;
}
-
+
public void setContentsURL( final String contentsURL ) {
this.contentsURL = ( contentsURL == null ) ? "" : contentsURL;
}
-
+
public String getIndexURL() {
return indexURL;
}
-
+
public void setIndexURL( final String indexURL ) {
this.indexURL = ( indexURL == null ) ? "" : indexURL;
}
-
+
public boolean isUseContentsURL() {
return useContentsURL;
}
-
+
public void setUseContentsURL( final boolean useContentsURL ) {
this.useContentsURL = useContentsURL;
}
-
+
public boolean isUseIndexURL() {
return useIndexURL;
}
-
+
public void setUseIndexURL( final boolean useIndexURL ) {
this.useIndexURL = useIndexURL;
}
-
+
public boolean isGenerateHTMLHelpFiles() {
return generateHTMLHelpFiles;
}
-
+
public void setGenerateHTMLHelpFiles( final boolean generateHTMLHelpFiles ) {
this.generateHTMLHelpFiles = generateHTMLHelpFiles;
}
-
+
public InterfaceList getReadInterfaceFiles() {
return readInterfaceFiles;
}
-
+
public void setReadInterfaceFiles( final InterfaceList readInterfaceFiles ) {
this.readInterfaceFiles = readInterfaceFiles;
}
-
-
+
+
// helping methods
//////////////////
-
- private void addParam( final boolean selected,
- final String name,
- final String value,
+
+ private void addParam( final boolean selected,
+ final String name,
+ final String value,
final List<String> list ) {
if( selected && value != null && !value.trim().equals( "" ) ) {
list.add( name );
list.add( value );
}
}
-
+
private void addReadInterfaces( final List<String> list ) {
InterfaceListEntry[] entries = readInterfaceFiles.getAll();
for( int i = 0; i < entries.length; i++ ) {
@@ -262,10 +260,8 @@ private void addReadInterfaces( final List<String> list ) {
}
}
}
-
+
private String readExecutableFromPreferences() {
- String key = IHaddockPreferenceNames.EXECUTABLE_NAME;
- Preferences preferences = HaddockPlugin.getDefault().getPluginPreferences();
- return preferences.getString( key );
+ return Platform.getPreferencesService().getString( HaddockPlugin.getPluginId(), IHaddockPreferenceNames.EXECUTABLE_NAME, null, null );
}
}
View
14 ...lipsefp.haskell.haddock/src/net/sf/eclipsefp/haskell/haddock/core/preferences/PreferenceInitializer.java
@@ -2,26 +2,24 @@
package net.sf.eclipsefp.haskell.haddock.core.preferences;
import net.sf.eclipsefp.haskell.haddock.HaddockPlugin;
-
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
-/** <p>initializer for the GHC compiler preferences (declared in the
+/** <p>initializer for the GHC compiler preferences (declared in the
* <code>plugin.xml</code>).</p>
- *
+ *
* @author Leif Frenzel
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer
implements IHaddockPreferenceNames {
-
+
// interface methods of AbstractPreferenceInitializer
/////////////////////////////////////////////////////
-
+
@Override
public void initializeDefaultPreferences() {
- Preferences prefs = HaddockPlugin.getDefault().getPluginPreferences();
// at least a chance it's on the PATH
- prefs.setDefault( EXECUTABLE_NAME, "haddock" );
+ new DefaultScope().getNode( HaddockPlugin.getPluginId() ).put( EXECUTABLE_NAME, "haddock" );
}
}
View
29 net.sf.eclipsefp.haskell.hugs/src/net/sf/eclipsefp/haskell/hugs/HugsPlugin.java
@@ -2,13 +2,11 @@
package net.sf.eclipsefp.haskell.hugs;
import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/** <p>The main plugin class to be used in the desktop.</p>
*
- * @author The mighty PDE wizard
+ * @author The mighty PDE wizard
*/
public class HugsPlugin extends AbstractUIPlugin {
@@ -27,20 +25,29 @@ public static HugsPlugin getDefault() {
public static String getPluginId() {
return getDefault().getBundle().getSymbolicName();
}
-
-
+
+
// logging and tracing
//////////////////////
-
+
public static void log( final String message, final Throwable throwable ) {
- Status status = new Status( IStatus.ERROR,
- getPluginId(),
- IStatus.OK,
- message,
+ Status status = new Status( IStatus.ERROR,
+ getPluginId(),
+ IStatus.OK,
+ message,
+ throwable );
+ getDefault().getLog().log( status );
+ }
+
+ public static void log( final Throwable throwable ) {
+ Status status = new Status( IStatus.ERROR,
+ getPluginId(),
+ IStatus.OK,
+ throwable.getMessage(),
throwable );
getDefault().getLog().log( status );
}
-
+
public static boolean isTracing() {
String option = getPluginId() + "/trace/calls";
String value = Platform.getDebugOption( option );
View
18 net.sf.eclipsefp.haskell.hugs/src/net/sf/eclipsefp/haskell/hugs/core/Util.java
@@ -2,28 +2,24 @@
package net.sf.eclipsefp.haskell.hugs.core;
import java.io.File;
-
+import net.sf.eclipsefp.haskell.core.project.IHaskellProject;
+import net.sf.eclipsefp.haskell.core.project.IImportLibrary;
import net.sf.eclipsefp.haskell.hugs.HugsPlugin;
import net.sf.eclipsefp.haskell.hugs.core.preferences.IHugsPreferenceNames;
-
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Preferences;
-
-import net.sf.eclipsefp.haskell.core.project.IHaskellProject;
-import net.sf.eclipsefp.haskell.core.project.IImportLibrary;
+import org.eclipse.core.runtime.Platform;
/** <p>contains common helping functionality.</p>
- *
+ *
* @author Leif Frenzel
*/
public class Util {
private static final String SEP = File.pathSeparator;
-
+
public static String getCompilerExecutable() {
- Preferences prefs = HugsPlugin.getDefault().getPluginPreferences();
- String pref = prefs.getString( IHugsPreferenceNames.EXECUTABLE_NAME );
-
+ String pref = Platform.getPreferencesService().getString( HugsPlugin.getPluginId(), IHugsPreferenceNames.EXECUTABLE_NAME, null, null );
+
String result = "hugs";
if( pref != null && !pref.equals( "" ) ) {
result = pref;
View
20 net.sf.eclipsefp.haskell.hugs/src/net/sf/eclipsefp/haskell/hugs/core/preferences/PreferenceInitializer.java
@@ -2,11 +2,9 @@
package net.sf.eclipsefp.haskell.hugs.core.preferences;
import net.sf.eclipsefp.haskell.hugs.HugsPlugin;
+import org.eclipse.core.runtime.preferences.*;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-
-/** <p>initializer for the HUGS preferences (declared in the
+/** <p>initializer for the HUGS preferences (declared in the
* <code>plugin.xml</code>).</p>
*
* @author Leif Frenzel
@@ -14,22 +12,22 @@
public class PreferenceInitializer extends AbstractPreferenceInitializer
implements IHugsPreferenceNames {
-
+
// interface methods of AbstractPreferenceInitializer
/////////////////////////////////////////////////////
-
+
@Override
public void initializeDefaultPreferences() {
- Preferences prefs = HugsPlugin.getDefault().getPluginPreferences();
+ IEclipsePreferences prefs = new DefaultScope().getNode( HugsPlugin.getPluginId() );
initializeDefaultValues( prefs );
}
-
+
// helping methods
//////////////////
-
- private void initializeDefaultValues( final Preferences prefs ) {
- prefs.setDefault( EXECUTABLE_NAME, "hugs" );
+
+ private void initializeDefaultValues( final IEclipsePreferences prefs ) {
+ prefs.put( EXECUTABLE_NAME, "hugs" );
// TODO more
}
}
View
9 net.sf.eclipsefp.haskell.hugs/src/net/sf/eclipsefp/haskell/hugs/ui/preferences/HugsPreferencePage.java
@@ -6,7 +6,7 @@
import net.sf.eclipsefp.haskell.hugs.HugsPlugin;
import net.sf.eclipsefp.haskell.hugs.core.IHugsParameters;
import net.sf.eclipsefp.haskell.hugs.core.preferences.IHugsPreferenceNames;
-
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
@@ -14,6 +14,7 @@
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.osgi.service.prefs.BackingStoreException;
/** <p>The preference page for the HUGS preferences.</p>
@@ -66,7 +67,11 @@ public void dispose() {
@Override
public boolean performOk() {
overlayStore.propagate();
- HugsPlugin.getDefault().savePluginPreferences();
+ try {
+ new InstanceScope().getNode(HugsPlugin.getPluginId()).flush();
+ } catch( BackingStoreException ex ) {
+ HugsPlugin.log( ex );
+ }
return true;
}
View
12 .../eclipsefp/haskell/ui/internal/editors/haskell/codeassist/WorkbenchHaskellCompletionContext_PDETest.java
@@ -14,13 +14,13 @@
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
-import junit.framework.TestCase;
import net.sf.eclipsefp.haskell.core.halamo.HaskellLanguageModel;
import net.sf.eclipsefp.haskell.core.halamo.ICompilationUnit;
import net.sf.eclipsefp.haskell.core.halamo.IHaskellModel;
import net.sf.eclipsefp.haskell.core.halamo.IHaskellModelManager;
import net.sf.eclipsefp.haskell.core.internal.util.TestHaskellProject;
import net.sf.eclipsefp.haskell.core.parser.IHaskellParser;
+import net.sf.eclipsefp.haskell.core.test.TestCaseWithPreferences;
import net.sf.eclipsefp.haskell.ui.internal.editors.haskell.codeassist.doubles.StubViewer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
@@ -33,21 +33,23 @@
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
-public class WorkbenchHaskellCompletionContext_PDETest extends TestCase {
+public class WorkbenchHaskellCompletionContext_PDETest extends TestCaseWithPreferences {
private TestHaskellProject fRightHandle;
private TestHaskellProject fWrongHandle;
@Override
- protected void setUp() throws CoreException {
- fRightHandle = new TestHaskellProject("fibb");
- fWrongHandle = new TestHaskellProject("qsort");
+ protected void setUp() throws Exception {
+ super.setUp();
+ fRightHandle = new TestHaskellProject("fibb", getCorePrefs());
+ fWrongHandle = new TestHaskellProject("qsort", getCorePrefs());
}
@Override
protected void tearDown() throws Exception {
fRightHandle.destroy();
fWrongHandle.destroy();
+ super.tearDown();
}
public void testFetchesCorrectLanguageModel() throws CoreException {
View
7 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/preferences/NewHaskellProjectPP.java
@@ -32,6 +32,7 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.osgi.service.prefs.BackingStoreException;
/** <p>the preference page for new Haskell projects. The user can pre-define
@@ -319,7 +320,11 @@ public boolean performOk() {
Text text = alTextControls.get( i );
String key = ( String )text.getData();
store.setValue( key, text.getText() );
- }
+ }
+ try {
+ new InstanceScope().getNode(HaskellCorePlugin.getPluginId()).flush();
+ } catch( BackingStoreException ex ) {
+ HaskellCorePlugin.log( ex );
}
return super.performOk();
}
View
8 ...sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/preferences/editor/HaskellEditorPP.java
@@ -5,6 +5,7 @@
import net.sf.eclipsefp.common.ui.preferences.Tab;
import net.sf.eclipsefp.common.ui.preferences.overlay.OverlayPreferenceStore;
import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
@@ -17,6 +18,7 @@
import org.eclipse.ui.editors.text.TextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
+import org.osgi.service.prefs.BackingStoreException;
/** <p>the preference page for the Haskell editor.</p>
@@ -70,7 +72,11 @@ public void dispose() {
@Override
public boolean performOk() {
overlayStore.propagate();
- HaskellUIPlugin.getDefault().savePluginPreferences();
+ try {
+ new InstanceScope().getNode(HaskellUIPlugin.getPluginId()).flush();
+ } catch( BackingStoreException ex ) {
+ HaskellUIPlugin.log( ex );
+ }
return true;
}
View
32 ....haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/preferences/hsimpls/InstalledImplementationsPP.java
@@ -8,7 +8,9 @@
import net.sf.eclipsefp.haskell.core.preferences.ICorePreferenceNames;
import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
-import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -21,6 +23,7 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.osgi.service.prefs.BackingStoreException;
/** <p>the preference page for installed Haskell implementations. A Haskell
@@ -73,15 +76,21 @@ protected Control createContents( final Composite parent ) {
@Override
public boolean performOk() {
- String key = ICorePreferenceNames.HS_IMPLEMENTATIONS;
- getPrefs().setValue( key, implementationsBlock.getPref() );
+ IEclipsePreferences node = new InstanceScope().getNode( HaskellCorePlugin.getPluginId() );
+
+ node.put( ICorePreferenceNames.HS_IMPLEMENTATIONS, implementationsBlock.getPref() );
IHsImplementation impl = implementationsBlock.getCheckedHsImplementation();
String name = "";
if( impl != null ) {
name = impl.getName();
}
- getPrefs().setValue( ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION, name );
- HaskellCorePlugin.getDefault().savePluginPreferences();
+ node.put( ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION, name );
+
+ try {
+ node.flush();
+ } catch( BackingStoreException ex ) {
+ HaskellUIPlugin.log( ex );
+ }
IDialogSettings settings = HaskellUIPlugin.getDefault().getDialogSettings();
implementationsBlock.saveColumnSettings( settings, DIALOG_SETTINGS_ID );
@@ -141,16 +150,11 @@ public void selectionChanged( final SelectionChangedEvent event ) {
}
private void applyInitialValue() {
- String key = ICorePreferenceNames.HS_IMPLEMENTATIONS;
- String value = getPrefs().getString( key );
- implementationsBlock.applyPref( value );
+ String impls = Platform.getPreferencesService().getString( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.HS_IMPLEMENTATIONS, null, null );
+ implementationsBlock.applyPref( impls );
- String selKey = ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION;
- String name = getPrefs().getString( selKey );
- implementationsBlock.setCheckedHsImplementation( name );
+ String sel = Platform.getPreferencesService().getString( HaskellCorePlugin.getPluginId(), ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION, null, null );
+ implementationsBlock.setCheckedHsImplementation( sel );
}
- private Preferences getPrefs() {
- return HaskellCorePlugin.getDefault().getPluginPreferences();
- }
}
View
2  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/scion/ScionManager.java
@@ -47,7 +47,7 @@
/**
* Used to alert the user of Scion startup failure only once per session.
*/
- private boolean serverStartupErrorReported = false;
+ private boolean serverStartupErrorReported = true; // TODO TtC set back to false
public ScionManager() {
// the work is done in the start() method
View
17 ...askell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/projectexplorer/HaskellResourceExtensionCP.java
@@ -16,9 +16,10 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
-import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.navigator.ICommonContentExtensionSite;
@@ -87,16 +88,16 @@ public void inputChanged( final Viewer viewer,
// TODO lf note to self: config -> navigator service -> can be used to
// get state information from the View
public void init( final ICommonContentExtensionSite config ) {
- Preferences prefs = HaskellCorePlugin.getDefault().getPluginPreferences();
- prefs.addPropertyChangeListener( new IPropertyChangeListener() {
- public void propertyChange( final PropertyChangeEvent event ) {
- String prop = event.getProperty();
+ IEclipsePreferences node = new InstanceScope().getNode( HaskellCorePlugin.getPluginId() );
+ node.addPreferenceChangeListener( new IPreferenceChangeListener() {
+ public void preferenceChange( final PreferenceChangeEvent event ) {
+ String prop = event.getKey();
if( ICorePreferenceNames.HS_IMPLEMENTATIONS.equals( prop )
|| ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION.equals( prop ) ) {
config.getService().update();
}
}
- } );
+ });
}
public void restoreState( final IMemento memento ) {
Please sign in to comment.
Something went wrong with that request. Please try again.