Author: koen.aers(a)jboss.com
Date: 2011-06-27 05:45:56 -0400 (Mon, 27 Jun 2011)
New Revision: 32370
Added:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/
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/
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/preferences/ForgeInstallationsTest.java
Removed:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeInstallations.java
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeInstallationsTest.java
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/META-INF/MANIFEST.MF
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeRuntime.java
trunk/forge/tests/org.jboss.tools.forge.core.test/META-INF/MANIFEST.MF
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeLaunchHelperTest.java
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeRuntimeTest.java
Log:
remove the compilation errors in ForgeLaunchHelper
Modified: trunk/forge/plugins/org.jboss.tools.forge.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/META-INF/MANIFEST.MF 2011-06-27
08:45:46 UTC (rev 32369)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/META-INF/MANIFEST.MF 2011-06-27
09:45:56 UTC (rev 32370)
@@ -9,5 +9,6 @@
org.eclipse.jdt.launching;bundle-version="3.6.0"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.forge.core,
+ org.jboss.tools.forge.core.preferences,
org.jboss.tools.forge.core.process
Bundle-Activator: org.jboss.tools.forge.core.ForgeCorePlugin
Added:
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
(rev 0)
+++
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/preferences/ForgeInstallations.java 2011-06-27
09:45:56 UTC (rev 32370)
@@ -0,0 +1,166 @@
+package org.jboss.tools.forge.core.preferences;
+
+import java.util.List;
+
+import org.jboss.tools.forge.core.process.ForgeRuntime;
+
+public class ForgeInstallations {
+
+ private static final String PREF_FORGE_INSTALLATIONS = "installations";
+
+ private static List<ForgeRuntime> installations = null;
+ private static ForgeRuntime defaultInstallation = null;
+
+ public static ForgeRuntime[] getInstallations() {
+// if (installations == null) {
+// initializeInstallations();
+// }
+ return (ForgeRuntime[])installations.toArray(new ForgeRuntime[installations.size()]);
+ }
+
+ public static ForgeRuntime getDefault() {
+// if (installations == null) {
+// initializeInstallations();
+// }
+ return defaultInstallation;
+ }
+
+// private static IEclipsePreferences getForgeCorePreferences() {
+// return InstanceScope.INSTANCE.getNode(ForgeCorePlugin.PLUGIN_ID);
+// }
+//
+// private static void initializeInstallations() {
+// String installPrefsXml = getForgeCorePreferences().get(PREF_FORGE_INSTALLATIONS,
null);
+// if (installPrefsXml == null || "".equals(installPrefsXml)) {
+// createInitialInstallations();
+// installPrefsXml = getForgeCorePreferences().get(PREF_FORGE_INSTALLATIONS, null);
+// }
+// initializeFromXml(installPrefsXml);
+// }
+//
+// private static void initializeFromXml(String installPrefsXml) {
+// if (installPrefsXml == null) return;
+// DocumentBuilder documentBuilder = newDocumentBuilder();
+// if (documentBuilder == null) return;
+// InputStream inputStream = createInputStream(installPrefsXml);
+// if (inputStream == null) return;
+// installations = new ArrayList<ForgeRuntime>();
+// Document document = parseInstallations(documentBuilder, inputStream);
+// Element installationsElement = document.getDocumentElement();
+// String defaultInstallationName =
installationsElement.getAttribute("default");
+// NodeList nodeList = installationsElement.getChildNodes();
+// for (int i = 0; i < nodeList.getLength(); i++) {
+// Node node = nodeList.item(i);
+// if (node.getNodeType() == Node.ELEMENT_NODE) {
+// Element element = (Element)node;
+// String name = element.getAttribute("name");
+// String location = element.getAttribute("location");
+// ForgeRuntime newInstallation = new ForgeRuntime(name, location);
+// installations.add(newInstallation);
+// if (name.equals(defaultInstallationName)) {
+// defaultInstallation = newInstallation;
+// }
+// }
+// }
+// }
+//
+// private static Document parseInstallations(DocumentBuilder documentBuilder,
InputStream inputStream) {
+// Document result = null;
+// try {
+// result = documentBuilder.parse(inputStream);
+// } catch (SAXException e) {
+// ForgeUIPlugin.log(e);
+// } catch (IOException e) {
+// ForgeUIPlugin.log(e);
+// }
+// return result;
+// }
+//
+// private static InputStream createInputStream(String string) {
+// InputStream result = null;
+// try {
+// result = new BufferedInputStream(new
ByteArrayInputStream(string.getBytes("UTF8")));
+// } catch (UnsupportedEncodingException e) {
+// ForgeUIPlugin.log(e);
+// }
+// return result;
+// }
+//
+// private static DocumentBuilder newDocumentBuilder() {
+// try {
+// return DocumentBuilderFactory.newInstance().newDocumentBuilder();
+// } catch (ParserConfigurationException e) {
+// ForgeUIPlugin.log(e);
+// return null;
+// }
+// }
+//
+// private static Document createEmptyDocument() {
+// DocumentBuilder documentBuilder = newDocumentBuilder();
+// if (documentBuilder == null) {
+// return null;
+// } else {
+// return documentBuilder.newDocument();
+// }
+// }
+//
+// private static String serializeDocument(Document doc) throws TransformerException,
IOException {
+// ByteArrayOutputStream s = new ByteArrayOutputStream();
+// TransformerFactory factory = TransformerFactory.newInstance();
+// Transformer transformer = factory.newTransformer();
+// transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+// DOMSource source = new DOMSource(doc);
+// StreamResult outputTarget = new StreamResult(s);
+// transformer.transform(source, outputTarget);
+// return s.toString("UTF8");
+// }
+//
+// private static void createInitialInstallations() {
+// try {
+// File file = FileLocator.getBundleFile(ForgeUIPlugin.getDefault().getBundle());
+// defaultInstallation = new ForgeInstallation("embedded",
file.getAbsolutePath());
+// installations = new ArrayList<ForgeInstallation>();
+// installations.add(defaultInstallation);
+// saveInstallations();
+// } catch (IOException e) {
+// ForgeUIPlugin.log(e);
+// }
+// }
+//
+// public static void setInstallations(ForgeInstallation[] installs, ForgeInstallation
defaultInstall) {
+// installations.clear();
+// for (ForgeInstallation install : installs) {
+// installations.add(install);
+// }
+// defaultInstallation = defaultInstall;
+// saveInstallations();
+// }
+//
+// private static void saveInstallations() {
+// try {
+// String xml = serializeDocument(createInstallationsDocument());
+// ForgeUIPlugin.getDefault().getPreferenceStore().setValue(PREF_FORGE_INSTALLATIONS,
xml);
+// } catch (IOException e) {
+// ForgeUIPlugin.log(e);
+// } catch (TransformerException e) {
+// ForgeUIPlugin.log(e);
+// }
+// }
+//
+// private static Document createInstallationsDocument() {
+// Document document = createEmptyDocument();
+// if (document == null) return null;
+// Element main = document.createElement("forgeInstallations");
+// document.appendChild(main);
+// for (ForgeInstallation installation : installations) {
+// Element element = document.createElement("installation");
+// element.setAttribute("name", installation.getName());
+// element.setAttribute("location", installation.getLocation());
+// main.appendChild(element);
+// }
+// main.setAttribute("default", defaultInstallation.getName());
+// return document;
+// }
+
+}
Deleted:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeInstallations.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeInstallations.java 2011-06-27
08:45:46 UTC (rev 32369)
+++
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeInstallations.java 2011-06-27
09:45:56 UTC (rev 32370)
@@ -1,5 +0,0 @@
-package org.jboss.tools.forge.core.process;
-
-public class ForgeInstallations {
-
-}
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java 2011-06-27
08:45:46 UTC (rev 32369)
+++
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java 2011-06-27
09:45:56 UTC (rev 32370)
@@ -144,10 +144,10 @@
return result;
}
- public static IProcess launch(ForgeRuntime runtime) {
+ public static IProcess launch(String name, String location) {
IProcess result = null;
- String launchConfigurationName = runtime.getName() + System.currentTimeMillis();
- List<String> classPath = createClassPath(runtime.getLocation());
+ String launchConfigurationName = name + System.currentTimeMillis();
+ List<String> classPath = createClassPath(location);
if (classPath != null) {
ILaunch launch = launch(launchConfigurationName, classPath);
removeLaunchConfiguration(launchConfigurationName);
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeRuntime.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeRuntime.java 2011-06-27
08:45:46 UTC (rev 32369)
+++
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeRuntime.java 2011-06-27
09:45:56 UTC (rev 32370)
@@ -1,39 +1,8 @@
package org.jboss.tools.forge.core.process;
-import java.beans.PropertyChangeSupport;
-
-import org.eclipse.debug.core.model.IProcess;
-
-public class ForgeRuntime {
+public interface ForgeRuntime {
- public static final String STATE_NOT_RUNNING =
"org.jboss.tools.forge.notRunning";
- public static final String STATE_RUNNING = "org.jboss.tools.forge.running";
- public static final String STATE_STARTING = "org.jboss.tools.forge.starting";
- public static final String STATE_STOPPING = "org.jboss.tools.forge.stopping";
-
- private IProcess forgeProcess = null;
- private String runtimeState = STATE_NOT_RUNNING;
- private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
-
- private String name;
- private String location;
-
- public ForgeRuntime(String name, String location) {
- this.name = name;
- this.location = location;
- }
-
- public void start() {
- if (!isTerminated()) return;
-
- }
-
- public void stop() {
- if (isTerminated()) return;
- }
-
- public boolean isTerminated() {
- return forgeProcess == null || forgeProcess.isTerminated();
- }
+ String getName();
+ String getLocation();
}
Modified: trunk/forge/tests/org.jboss.tools.forge.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/forge/tests/org.jboss.tools.forge.core.test/META-INF/MANIFEST.MF 2011-06-27
08:45:46 UTC (rev 32369)
+++ trunk/forge/tests/org.jboss.tools.forge.core.test/META-INF/MANIFEST.MF 2011-06-27
09:45:56 UTC (rev 32370)
@@ -8,4 +8,5 @@
Require-Bundle: org.junit;bundle-version="3.8.2",
org.eclipse.core.runtime;bundle-version="3.7.0",
org.jboss.tools.forge.core;bundle-version="1.0.0",
- org.eclipse.debug.core;bundle-version="3.7.0"
+ org.eclipse.debug.core;bundle-version="3.7.0",
+ org.eclipse.ui.workbench;bundle-version="3.7.0"
Added:
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
(rev 0)
+++
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/preferences/ForgeInstallationsTest.java 2011-06-27
09:45:56 UTC (rev 32370)
@@ -0,0 +1,34 @@
+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.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());
+ }
+
+}
Deleted:
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeInstallationsTest.java
===================================================================
---
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeInstallationsTest.java 2011-06-27
08:45:46 UTC (rev 32369)
+++
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeInstallationsTest.java 2011-06-27
09:45:56 UTC (rev 32370)
@@ -1,7 +0,0 @@
-package org.jboss.tools.forge.core.process;
-
-import junit.framework.TestCase;
-
-public class ForgeInstallationsTest extends TestCase {
-
-}
Modified:
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeLaunchHelperTest.java
===================================================================
---
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeLaunchHelperTest.java 2011-06-27
08:45:46 UTC (rev 32369)
+++
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeLaunchHelperTest.java 2011-06-27
09:45:56 UTC (rev 32370)
@@ -19,12 +19,20 @@
public class ForgeLaunchHelperTest {
+ private static String TEST_LOCATION;
+
private IProcess forgeProcess = null;
- private ForgeRuntime forgeRuntime = null;
+
+ static {
+ try {
+ TEST_LOCATION =
FileLocator.getBundleFile(Platform.getBundle("org.jboss.tools.forge.runtime")).getAbsolutePath();
+ } catch (IOException e) {
+ TEST_LOCATION = null;
+ }
+ }
@Before
public void setUp() throws Exception {
- forgeRuntime = new TestRuntime();
forgeProcess = null;
}
@@ -36,7 +44,6 @@
} catch (DebugException e) {}
}
forgeProcess = null;
- forgeRuntime = null;
}
@Test
@@ -44,7 +51,7 @@
new UIJob("testLaunch") {
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
- forgeProcess = ForgeLaunchHelper.launch(forgeRuntime);
+ forgeProcess = ForgeLaunchHelper.launch("test", TEST_LOCATION);
assertNotNull(forgeProcess);
assertFalse(forgeProcess.isTerminated());
} catch (RuntimeException e) {
@@ -56,17 +63,4 @@
}.schedule();
}
- private class TestRuntime extends ForgeRuntime {
- public String getName() {
- return "test";
- }
- public String getLocation() {
- try {
- return
FileLocator.getBundleFile(Platform.getBundle("org.jboss.tools.forge.runtime")).getAbsolutePath();
- } catch (IOException e) {
- return null;
- }
- }
- }
-
}
Modified:
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeRuntimeTest.java
===================================================================
---
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeRuntimeTest.java 2011-06-27
08:45:46 UTC (rev 32369)
+++
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeRuntimeTest.java 2011-06-27
09:45:56 UTC (rev 32370)
@@ -1,29 +1,27 @@
package org.jboss.tools.forge.core.process;
-import junit.framework.TestCase;
+import static org.junit.Assert.fail;
-import org.eclipse.core.runtime.Platform;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-public class ForgeRuntimeTest extends TestCase {
+public class ForgeRuntimeTest {
- private ForgeRuntime forgeRuntime;
-
- protected void setUp() {
- String location =
Platform.getBundle("org.jboss.tools.forge.runtime").getLocation();
- location = location.substring("reference:file:".length());
- forgeRuntime = new ForgeRuntime("forge-test", location);
+ private ForgeRuntime forgeRuntime = null;
+
+ @Before
+ public void setUp() throws Exception {
+// forgeRuntime = new ForgeRuntime("test", )
}
-
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
public void testStartStop() {
- assertTrue(forgeRuntime.isTerminated());
- forgeRuntime.start();
- assertFalse(forgeRuntime.isTerminated());
- forgeRuntime.stop();
- assertTrue(forgeRuntime.isTerminated());
+ fail("Not yet implemented");
}
-
- protected void tearDown() {
- forgeRuntime = null;
- }
}