Author: koen.aers(a)jboss.com
Date: 2011-06-29 15:01:27 -0400 (Wed, 29 Jun 2011)
New Revision: 32457
Added:
trunk/forge/plugins/org.jboss.tools.forge.core/plugin.xml
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgePreferenceInitializer.java
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/preferences/ForgePreferenceInitializerTest.java
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/build.properties
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgeInstallations.java
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/preferences/ForgeInstallationsTest.java
Log:
implemented forge preference initializer
Modified: trunk/forge/plugins/org.jboss.tools.forge.core/build.properties
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/build.properties 2011-06-29 17:24:30
UTC (rev 32456)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/build.properties 2011-06-29 19:01:27
UTC (rev 32457)
@@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.xml
Added: trunk/forge/plugins/org.jboss.tools.forge.core/plugin.xml
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/plugin.xml (rev
0)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/plugin.xml 2011-06-29 19:01:27 UTC (rev
32457)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+
class="org.jboss.tools.forge.core.preferences.ForgePreferenceInitializer">
+ </initializer>
+ </extension>
+
+</plugin>
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgeInstallations.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgeInstallations.java 2011-06-29
17:24:30 UTC (rev 32456)
+++
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgeInstallations.java 2011-06-29
19:01:27 UTC (rev 32457)
@@ -1,13 +1,14 @@
package org.jboss.tools.forge.core.preferences;
+import org.jboss.tools.forge.core.process.ForgeEmbeddedRuntime;
import org.jboss.tools.forge.core.process.ForgeRuntime;
public class ForgeInstallations {
-// private static final String PREF_FORGE_INSTALLATIONS = "installations";
+ static final String PREF_FORGE_INSTALLATIONS =
"org.jboss.tools.forge.core.installations";
// private static List<ForgeRuntime> installations = null;
- private static ForgeRuntime defaultInstallation = null;
+ private static ForgeRuntime DEFAULT_INSTALLATION = null;
// public static ForgeRuntime[] getInstallations() {
// if (installations == null) {
@@ -17,10 +18,10 @@
// }
public static ForgeRuntime getDefault() {
-// if (installations == null) {
-// initializeInstallations();
-// }
- return defaultInstallation;
+ if (DEFAULT_INSTALLATION == null) {
+ initializeInstallations();
+ }
+ return DEFAULT_INSTALLATION;
}
// private static IEclipsePreferences getForgeCorePreferences() {
@@ -35,6 +36,10 @@
// }
+ private static void initializeInstallations() {
+ DEFAULT_INSTALLATION = ForgeEmbeddedRuntime.INSTANCE;
+ }
+
// private static void initializeInstallations() {
// String installPrefsXml = getForgeCorePreferences().get(PREF_FORGE_INSTALLATIONS,
null);
// if (installPrefsXml == null || "".equals(installPrefsXml)) {
Added:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgePreferenceInitializer.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgePreferenceInitializer.java
(rev 0)
+++
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgePreferenceInitializer.java 2011-06-29
19:01:27 UTC (rev 32457)
@@ -0,0 +1,22 @@
+package org.jboss.tools.forge.core.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.jboss.tools.forge.core.ForgeCorePlugin;
+
+public class ForgePreferenceInitializer extends AbstractPreferenceInitializer {
+
+ static final String INITIAL_INSTALLATIONS_PREFERENCE =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"
standalone=\"no\"?>\n" +
+ "<forgeInstallations default=\"embedded\">" +
+ " <installation name=\"embedded\"/>" +
+ "</forgeInstallations>";
+
+ @Override
+ public void initializeDefaultPreferences() {
+ IEclipsePreferences preferences =
InstanceScope.INSTANCE.getNode(ForgeCorePlugin.PLUGIN_ID);
+ preferences.put(ForgeInstallations.PREF_FORGE_INSTALLATIONS,
INITIAL_INSTALLATIONS_PREFERENCE);
+ }
+
+}
Modified:
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/preferences/ForgeInstallationsTest.java
===================================================================
---
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/preferences/ForgeInstallationsTest.java 2011-06-29
17:24:30 UTC (rev 32456)
+++
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/preferences/ForgeInstallationsTest.java 2011-06-29
19:01:27 UTC (rev 32457)
@@ -1,34 +1,15 @@
package org.jboss.tools.forge.core.preferences;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import java.io.IOException;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
-import org.jboss.tools.forge.core.process.ForgeRuntime;
+import org.jboss.tools.forge.core.process.ForgeEmbeddedRuntime;
import org.junit.Test;
public class ForgeInstallationsTest {
- private static String defaultForgeLocation = null;
-
- static {
- try {
- defaultForgeLocation =
FileLocator.getBundleFile(Platform.getBundle("org.jboss.tools.forge.runtime")).getAbsolutePath();
- } catch (IOException e) {
- // ignore
- }
-
- }
-
@Test
public void testGetDefault() {
- ForgeRuntime forgeRuntime = ForgeInstallations.getDefault();
- assertNotNull(forgeRuntime);
- assertEquals("embedded", forgeRuntime.getName());
- assertEquals(defaultForgeLocation, forgeRuntime.getLocation());
+ assertEquals(ForgeEmbeddedRuntime.INSTANCE, ForgeInstallations.getDefault());
}
-
+
}
Added:
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/preferences/ForgePreferenceInitializerTest.java
===================================================================
---
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/preferences/ForgePreferenceInitializerTest.java
(rev 0)
+++
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/preferences/ForgePreferenceInitializerTest.java 2011-06-29
19:01:27 UTC (rev 32457)
@@ -0,0 +1,23 @@
+package org.jboss.tools.forge.core.preferences;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.jboss.tools.forge.core.ForgeCorePlugin;
+import org.junit.Test;
+
+public class ForgePreferenceInitializerTest {
+
+ @Test
+ public void testInitializeDefaultPreferences() {
+ IEclipsePreferences preferences =
InstanceScope.INSTANCE.getNode(ForgeCorePlugin.PLUGIN_ID);
+ assertNull(preferences.get(ForgeInstallations.PREF_FORGE_INSTALLATIONS, null));
+ new ForgePreferenceInitializer().initializeDefaultPreferences();
+ assertEquals(
+ ForgePreferenceInitializer.INITIAL_INSTALLATIONS_PREFERENCE,
+ preferences.get(ForgeInstallations.PREF_FORGE_INSTALLATIONS, null));
+ }
+
+}
Show replies by date