Author: snjeza
Date: 2011-04-03 12:52:26 -0400 (Sun, 03 Apr 2011)
New Revision: 30248
Modified:
trunk/runtime/features/org.jboss.tools.runtime.test.feature/feature.xml
trunk/runtime/features/org.jboss.tools.runtime.test.feature/pom.xml
trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF
trunk/runtime/plugins/org.jboss.tools.runtime.core/pom.xml
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/ServerDefinition.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF
trunk/runtime/plugins/org.jboss.tools.runtime.ui/pom.xml
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeContentProvider.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/EditRuntimePathDialog.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/SearchRuntimePathDialog.java
trunk/runtime/plugins/org.jboss.tools.runtime/META-INF/MANIFEST.MF
trunk/runtime/plugins/org.jboss.tools.runtime/pom.xml
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JbpmHandler.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java
trunk/runtime/tests/org.jboss.tools.runtime.test/META-INF/MANIFEST.MF
trunk/runtime/tests/org.jboss.tools.runtime.test/pom.xml
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/IRuntimeDetectionConstants.java
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java
Log:
JBIDE-8128 [JBossTools Runtimes] Allow user to select what runtime types to be added
Modified: trunk/runtime/features/org.jboss.tools.runtime.test.feature/feature.xml
===================================================================
--- trunk/runtime/features/org.jboss.tools.runtime.test.feature/feature.xml 2011-04-03
16:51:43 UTC (rev 30247)
+++ trunk/runtime/features/org.jboss.tools.runtime.test.feature/feature.xml 2011-04-03
16:52:26 UTC (rev 30248)
@@ -2,7 +2,7 @@
<feature
id="org.jboss.tools.runtime.test.feature"
label="Feature"
- version="1.0.0.qualifier">
+ version="1.3.0.qualifier">
<description>
%description
Modified: trunk/runtime/features/org.jboss.tools.runtime.test.feature/pom.xml
===================================================================
--- trunk/runtime/features/org.jboss.tools.runtime.test.feature/pom.xml 2011-04-03
16:51:43 UTC (rev 30247)
+++ trunk/runtime/features/org.jboss.tools.runtime.test.feature/pom.xml 2011-04-03
16:52:26 UTC (rev 30248)
@@ -8,6 +8,6 @@
</parent>
<groupId>org.jboss.tools.runtime.features</groupId>
<artifactId>org.jboss.tools.runtime.test.feature</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
\ No newline at end of file
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/META-INF/MANIFEST.MF 2011-04-03 16:51:43
UTC (rev 30247)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/META-INF/MANIFEST.MF 2011-04-03 16:52:26
UTC (rev 30248)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %BundleName
Bundle-SymbolicName: org.jboss.tools.runtime;singleton:=true
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Activator: org.jboss.tools.runtime.Activator
Bundle-Vendor: %BundleVendor
Require-Bundle: org.eclipse.core.runtime,
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/pom.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/pom.xml 2011-04-03 16:51:43 UTC (rev
30247)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/pom.xml 2011-04-03 16:52:26 UTC (rev
30248)
@@ -9,6 +9,6 @@
</parent>
<groupId>org.jboss.tools</groupId>
<artifactId>org.jboss.tools.runtime</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
\ No newline at end of file
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -32,18 +32,24 @@
droolsRuntimes.add(runtime);
}
}
+ initializeInternal(serverDefinitions, droolsRuntimes);
+ if (droolsRuntimes.size() > 0) {
+ DroolsRuntime[] dra = droolsRuntimes.toArray(new DroolsRuntime[0]);
+ DroolsRuntimeManager.setDroolsRuntimes(dra);
+ }
+
+ }
+
+ private void initializeInternal(List<ServerDefinition> serverDefinitions,
+ List<DroolsRuntime> droolsRuntimes) {
for (ServerDefinition serverDefinition : serverDefinitions) {
String type = serverDefinition.getType();
if (serverDefinition.isEnabled() && !droolsExists(serverDefinition)) {
- if (SOA_P.equals(type) || DROOLS.equals(type)) {
+ if (DROOLS.equals(type)) {
File droolsRoot = serverDefinition.getLocation(); //$NON-NLS-1$
if (droolsRoot.isDirectory()) {
DroolsRuntime runtime = new DroolsRuntime();
- if (SOA_P.equals(type)) {
- runtime.setName("Drools - " + serverDefinition.getName());
//$NON-NLS-1$
- } else {
- runtime.setName("Drools " + serverDefinition.getVersion()+ " -
" + serverDefinition.getName()); //$NON-NLS-1$
- }
+ runtime.setName("Drools " + serverDefinition.getVersion()+ " -
" + serverDefinition.getName()); //$NON-NLS-1$
runtime.setPath(droolsRoot.getAbsolutePath());
DroolsRuntimeManager.recognizeJars(runtime);
runtime.setDefault(true);
@@ -51,12 +57,8 @@
}
}
}
+ initializeInternal(serverDefinition.getIncludedServerDefinitions(), droolsRuntimes);
}
- if (droolsRuntimes.size() > 0) {
- DroolsRuntime[] dra = droolsRuntimes.toArray(new DroolsRuntime[0]);
- DroolsRuntimeManager.setDroolsRuntimes(dra);
- }
-
}
/**
@@ -118,4 +120,18 @@
}
return droolsExists(serverDefinition);
}
+
+ public static void calculateIncludedServerDefinition(
+ ServerDefinition serverDefinition) {
+ if (serverDefinition == null || !SOA_P.equals(serverDefinition.getType())) {
+ return;
+ }
+ File droolsRoot = serverDefinition.getLocation(); //$NON-NLS-1$
+ if (droolsRoot.isDirectory()) {
+ String name = "Drools - " + serverDefinition.getName(); //$NON-NLS-1$
+ ServerDefinition sd = new ServerDefinition(name, serverDefinition.getVersion(),
DROOLS, droolsRoot);
+ sd.setParent(serverDefinition);
+ serverDefinition.getIncludedServerDefinitions().add(sd);
+ }
+ }
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -13,6 +13,8 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Properties;
@@ -139,6 +141,7 @@
}
createJBossServer(serverDefinition.getLocation(),index,serverDefinition.getName(),serverDefinition.getName()
+ " " + RUNTIME); //$NON-NLS-1$
}
+ createJBossServerFromDefinitions(serverDefinition.getIncludedServerDefinitions());
}
}
@@ -373,10 +376,27 @@
ServerDefinition serverDefinition = new ServerDefinition(serverBean.getName(),
serverBean.getVersion(), serverBean.getType().getId(), new
File(serverBean.getLocation()));
serverDefinition.setDescription(includedRuntimes(serverDefinition));
+ calculateIncludedServerDefinition(serverDefinition);
return serverDefinition;
}
return null;
}
+
+ private void calculateIncludedServerDefinition(ServerDefinition serverDefinition) {
+ if (serverDefinition == null || serverDefinition.getType() == null) {
+ return;
+ }
+ serverDefinition.getIncludedServerDefinitions().clear();
+ String type = serverDefinition.getType();
+ if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || EWP.equals(type)) {
+ SeamHandler.calculateIncludedServerDefinition(serverDefinition);
+
+ }
+ if (SOA_P.equals(type)) {
+ DroolsHandler.calculateIncludedServerDefinition(serverDefinition);
+ JbpmHandler.calculateIncludedServerDefinition(serverDefinition);
+ }
+ }
@Override
public String includedRuntimes(ServerDefinition serverDefinition) {
@@ -436,4 +456,12 @@
}
return false;
}
+
+ @Override
+ public void computeIncludedServerDefinition(
+ ServerDefinition serverDefinition) {
+ calculateIncludedServerDefinition(serverDefinition);
+ }
+
+
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JbpmHandler.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JbpmHandler.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JbpmHandler.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -48,18 +48,11 @@
continue;
}
String type = serverDefinition.getType();
- if (SOA_P.equals(type)) {
- if (jbpmRoot.isDirectory()) {
- String version = JBPM3;
- if (isJbpm4(serverDefinition.getLocation().getAbsolutePath())) {
- version = JBPM4;
- }
- PreferencesManager.getInstance().initializeDefaultJbpmInstallation(serverDefinition.getName(),
jbpmRoot.getAbsolutePath(), version);
- }
- } else if (JBPM.equals(type)) {
+ if (JBPM.equals(type)) {
PreferencesManager.getInstance().addJbpmInstallation(serverDefinition.getName(),
jbpmRoot.getAbsolutePath(), serverDefinition.getVersion());
}
}
+ initializeRuntimes(serverDefinition.getIncludedServerDefinitions());
}
}
@@ -134,4 +127,21 @@
}
return jbpmExists(serverDefinition);
}
+
+ public static void calculateIncludedServerDefinition(
+ ServerDefinition serverDefinition) {
+ if (serverDefinition == null || !SOA_P.equals(serverDefinition.getType())) {
+ return;
+ }
+ File jbpmRoot = new File(serverDefinition.getLocation(),"jbpm-jpdl");
//$NON-NLS-1$
+ if (jbpmRoot.isDirectory()) {
+ String version = JBPM3;
+ if (isJbpm4(serverDefinition.getLocation().getAbsolutePath())) {
+ version = JBPM4;
+ }
+ ServerDefinition sd = new ServerDefinition(serverDefinition.getName(), version, JBPM,
jbpmRoot);
+ sd.setParent(serverDefinition);
+ serverDefinition.getIncludedServerDefinitions().add(sd);
+ }
+ }
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -41,14 +41,14 @@
public static File getSeamRoot(ServerDefinition serverDefinition) {
String type = serverDefinition.getType();
- if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || EWP.equals(type) ) {
- for (String folder : SEAM_HOME_FOLDER_OPTIONS) {
- File seamFile = new File(serverDefinition.getLocation(),folder); //$NON-NLS-1$
- if (seamFile != null && seamFile.isDirectory()) {
- return seamFile;
- }
- }
- }
+// if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || EWP.equals(type) )
{
+// for (String folder : SEAM_HOME_FOLDER_OPTIONS) {
+// File seamFile = new File(serverDefinition.getLocation(),folder); //$NON-NLS-1$
+// if (seamFile != null && seamFile.isDirectory()) {
+// return seamFile;
+// }
+// }
+// }
if (SEAM.equals(type)) {
return serverDefinition.getLocation();
}
@@ -59,23 +59,15 @@
Map<String, SeamRuntime> map = new HashMap<String,SeamRuntime>();
- // to fix
https://jira.jboss.org/jira/browse/JBDS-682
- // seam runtime initialization goes throug added servers first and
- // then process seam runtimes from bundled servers
for(ServerDefinition serverDefinition:serverDefinitions) {
if (!serverDefinition.isEnabled()) {
continue;
}
String type = serverDefinition.getType();
- if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || EWP.equals(type) )
{
- for (String folder : SEAM_HOME_FOLDER_OPTIONS) {
- File seamFile = new File(serverDefinition.getLocation(),folder); //$NON-NLS-1$
- addSeam(map, serverDefinition, seamFile);
- }
- }
if (SEAM.equals(type)) {
addSeam(map, serverDefinition, serverDefinition.getLocation());
}
+ initializeRuntimes(serverDefinition.getIncludedServerDefinitions());
}
// Initialize Seam Runtime from JBoss EAP
@@ -269,6 +261,22 @@
return builder.toString();
}
+ public static void calculateIncludedServerDefinition(
+ ServerDefinition serverDefinition) {
+ for (String folder : IJBossRuntimePluginConstants.SEAM_HOME_FOLDER_OPTIONS) {
+ File seamFile = new File(serverDefinition.getLocation(),folder); //$NON-NLS-1$
+ if (seamFile.exists() && seamFile.canRead() && seamFile.isDirectory())
{
+ String seamVersion = getSeamVersionFromManifest(seamFile.getAbsolutePath());
+ if (seamVersion != null) {
+ String name = "Seam " + serverDefinition.getName() + " " +
seamVersion; //$NON-NLS-1$ //$NON-NLS-2$
+ ServerDefinition sd = new ServerDefinition(name, seamVersion, SEAM,
seamFile.getAbsoluteFile());
+ sd.setParent(serverDefinition);
+ serverDefinition.getIncludedServerDefinitions().add(sd);
+ }
+ }
+ }
+ }
+
@Override
public boolean exists(ServerDefinition serverDefinition) {
if (serverDefinition == null || serverDefinition.getLocation() == null) {
@@ -281,4 +289,5 @@
String path = seamRoot.getAbsolutePath();
return seamExists(path);
}
+
}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF 2011-04-03
16:51:43 UTC (rev 30247)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF 2011-04-03
16:52:26 UTC (rev 30248)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %BundleName
Bundle-SymbolicName: org.jboss.tools.runtime.core;singleton:=true
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Activator: org.jboss.tools.runtime.core.RuntimeCoreActivator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/pom.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/pom.xml 2011-04-03 16:51:43 UTC
(rev 30247)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/pom.xml 2011-04-03 16:52:26 UTC
(rev 30248)
@@ -9,6 +9,6 @@
</parent>
<groupId>org.jboss.tools</groupId>
<artifactId>org.jboss.tools.runtime.core</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
\ No newline at end of file
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -123,5 +123,12 @@
int p1 = this.getPriority();
int p2 = o.getPriority();
return p1 - p2;
- }
+ }
+
+ @Override
+ public void computeIncludedServerDefinition(
+ ServerDefinition serverDefinition) {
+
+ }
+
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -47,4 +47,6 @@
int getPriority();
void setPriority(int priority);
+
+ void computeIncludedServerDefinition(ServerDefinition serverDefinition);
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/ServerDefinition.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/ServerDefinition.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/ServerDefinition.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -11,6 +11,8 @@
package org.jboss.tools.runtime.core.model;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author snjeza
@@ -25,6 +27,8 @@
private String description;
private boolean enabled = true;
private RuntimePath runtimePath;
+ private List<ServerDefinition> includedServerDefinitions = new
ArrayList<ServerDefinition>();
+ private ServerDefinition parent;
public ServerDefinition(String name, String version,
String type, File location) {
@@ -139,6 +143,16 @@
this.runtimePath = runtimePath;
}
+ public List<ServerDefinition> getIncludedServerDefinitions() {
+ return includedServerDefinitions;
+ }
+
+ public ServerDefinition getParent() {
+ return parent;
+ }
+
+ public void setParent(ServerDefinition parent) {
+ this.parent = parent;
+ }
-
}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF 2011-04-03
16:51:43 UTC (rev 30247)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF 2011-04-03
16:52:26 UTC (rev 30248)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %BundleName
Bundle-SymbolicName: org.jboss.tools.runtime.ui;singleton:=true
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Activator: org.jboss.tools.runtime.ui.RuntimeUIActivator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/pom.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/pom.xml 2011-04-03 16:51:43 UTC (rev
30247)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/pom.xml 2011-04-03 16:52:26 UTC (rev
30248)
@@ -9,6 +9,6 @@
</parent>
<groupId>org.jboss.tools</groupId>
<artifactId>org.jboss.tools.runtime.ui</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
\ No newline at end of file
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeContentProvider.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeContentProvider.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeContentProvider.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -12,7 +12,7 @@
import java.util.List;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.jboss.tools.runtime.core.model.ServerDefinition;
@@ -20,14 +20,14 @@
* @author snjeza
*
*/
-public class RuntimeContentProvider implements IStructuredContentProvider {
+public class RuntimeContentProvider implements ITreeContentProvider {
private List<ServerDefinition> serverDefinitions;
public RuntimeContentProvider(List<ServerDefinition> serverDefinitions) {
this.serverDefinitions = serverDefinitions;
}
-
+
public Object[] getElements(Object inputElement) {
return serverDefinitions.toArray();
}
@@ -40,4 +40,18 @@
serverDefinitions = (List<ServerDefinition>) newInput;
}
+ public boolean hasChildren(Object element) {
+ return ((ServerDefinition) element).getIncludedServerDefinitions().size() > 0;
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ List<ServerDefinition> list = ((ServerDefinition)
parentElement).getIncludedServerDefinitions();
+ return list.toArray();
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ return ((ServerDefinition) element).getParent();
+ }
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -29,7 +29,8 @@
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.PreferenceDialog;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
@@ -39,8 +40,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.WorkbenchException;
@@ -89,6 +89,8 @@
private static final String SERVER_DEFINITION = "serverDefinition";
private static final String NAME = "name";
+
+ private static final String INCLUDED_DEFINITION = "included";
private static final String VERSION = "version";
@@ -101,7 +103,11 @@
private static final String ENABLED = "enabled";
public static final String FIRST_START = "firstStart"; //$NON-NLS-1$
+
+ public static final String PREFERENCES_VERSION = "version"; //$NON-NLS-1$
+ private static final String RUNTIME_PREFERENCES_VERSION = "2"; //$NON-NLS-1$
+
private List<RuntimePath> runtimePaths = new ArrayList<RuntimePath>();
private Set<IRuntimeDetector> runtimeDetectors;
@@ -155,27 +161,28 @@
RuntimeUIActivator.getDefault().getLog().log(status);
}
- public static CheckboxTableViewer createRuntimeViewer(final List<RuntimePath>
runtimePaths2, Composite composite, int heightHint) {
+ public static CheckboxTreeViewer createRuntimeViewer(final List<RuntimePath>
runtimePaths2, Composite composite, int heightHint) {
GridData gd;
- CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(composite, SWT.V_SCROLL
+ CheckboxTreeViewer viewer = new CheckboxTreeViewer(composite, SWT.V_SCROLL
| SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
- Table table = viewer.getTable();
+
+ Tree tree = viewer.getTree();
gd = new GridData(GridData.FILL_BOTH);
GC gc = new GC( composite);
FontMetrics fontMetrics = gc.getFontMetrics( );
gc.dispose( );
gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, heightHint);
- table.setLayoutData(gd);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
+ tree.setLayoutData(gd);
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
- String[] columnNames = new String[] { "Name", "Version",
"Type", "Location", "Description"};
- int[] columnWidths = new int[] {140, 50, 50, 245, 200};
+ String[] columnNames = new String[] { "Name", "Version",
"Type", "Location"};
+ int[] columnWidths = new int[] {300, 100, 50, 200};
for (int i = 0; i < columnNames.length; i++) {
- TableColumn tc = new TableColumn(table, SWT.LEFT);
- tc.setText(columnNames[i]);
- tc.setWidth(columnWidths[i]);
+ TreeViewerColumn tc = new TreeViewerColumn(viewer, SWT.NONE);
+ tc.getColumn().setText(columnNames[i]);
+ tc.getColumn().setWidth(columnWidths[i]);
}
viewer.setLabelProvider(new RuntimeLabelProvider());
@@ -191,7 +198,7 @@
return viewer;
}
- public static void refreshRuntimes(Shell shell, final List<RuntimePath>
runtimePaths, final CheckboxTableViewer viewer, boolean needRefresh, int heightHint) {
+ public static void refreshRuntimes(Shell shell, final List<RuntimePath>
runtimePaths, final CheckboxTreeViewer viewer, boolean needRefresh, int heightHint) {
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
@@ -280,6 +287,8 @@
}
Reader reader = new StringReader(runtimes);
XMLMemento memento = XMLMemento.createReadRoot(reader);
+ String preferencesVersion = memento.getString(PREFERENCES_VERSION);
+ boolean computeIncluded = preferencesVersion == null;
IMemento[] nodes = memento.getChildren(RUNTIME_PATH);
for (IMemento node:nodes) {
String path = node.getString(PATH);
@@ -299,24 +308,48 @@
IMemento serverDefinitionsNode = node.getChild(SERVER_DEFINITIONS);
IMemento[] sdNodes = serverDefinitionsNode.getChildren(SERVER_DEFINITION);
for (IMemento sdNode:sdNodes) {
- String name = sdNode.getString(NAME);
- String version = sdNode.getString(VERSION);
- String type = sdNode.getString(TYPE);
- String location = sdNode.getString(LOCATION);
- String description = sdNode.getString(DESCRIPTION);
- boolean enabled = sdNode.getBoolean(ENABLED);
- ServerDefinition serverDefinition =
- new ServerDefinition(name, version, type, new File(location));
- serverDefinition.setDescription(description);
- serverDefinition.setEnabled(enabled);
+ ServerDefinition serverDefinition = createServerDefinition(sdNode);
serverDefinition.setRuntimePath(runtimePath);
+ IMemento includedDefinition = sdNode.getChild(INCLUDED_DEFINITION);
+ if (includedDefinition != null) {
+ IMemento[] includedNodes = includedDefinition
+ .getChildren(SERVER_DEFINITION);
+ for (IMemento includedNode : includedNodes) {
+ ServerDefinition included = createServerDefinition(includedNode);
+ included.setRuntimePath(runtimePath);
+ included.setParent(serverDefinition);
+ serverDefinition.getIncludedServerDefinitions().add(
+ included);
+ }
+ }
runtimePath.getServerDefinitions().add(serverDefinition);
}
runtimePaths.add(runtimePath);
-
}
+ if (computeIncluded) {
+ for(ServerDefinition definition:getServerDefinitions()) {
+ Set<IRuntimeDetector> detectors = RuntimeCoreActivator.getRuntimeDetectors();
+ for (IRuntimeDetector detector:detectors) {
+ detector.computeIncludedServerDefinition(definition);
+ }
+ }
+ }
}
+ private ServerDefinition createServerDefinition(IMemento node) {
+ String name = node.getString(NAME);
+ String version = node.getString(VERSION);
+ String type = node.getString(TYPE);
+ String location = node.getString(LOCATION);
+ String description = node.getString(DESCRIPTION);
+ boolean enabled = node.getBoolean(ENABLED);
+ ServerDefinition serverDefinition =
+ new ServerDefinition(name, version, type, new File(location));
+ serverDefinition.setDescription(description);
+ serverDefinition.setEnabled(enabled);
+ return serverDefinition;
+ }
+
private static IEclipsePreferences getPreferences() {
if (prefs == null) {
prefs = new ConfigurationScope().getNode(PLUGIN_ID);
@@ -331,21 +364,15 @@
XMLMemento memento = XMLMemento.createWriteRoot(RUNTIME_PATHS);
Writer writer = null;
try {
+ memento.putString(PREFERENCES_VERSION, RUNTIME_PREFERENCES_VERSION);
for (RuntimePath runtimePath:runtimePaths) {
IMemento runtimePathNode = memento.createChild(RUNTIME_PATH);
runtimePathNode.putString(PATH, runtimePath.getPath());
runtimePathNode.putBoolean(SCAN_ON_EVERY_STAERTUP,
runtimePath.isScanOnEveryStartup());
runtimePathNode.putString(TIMESTAMP, String.valueOf(runtimePath.getTimestamp()));
- IMemento serverDefintionsNode = runtimePathNode.createChild(SERVER_DEFINITIONS);
- for (ServerDefinition serverDefinition:runtimePath.getServerDefinitions()) {
- IMemento sdNode = serverDefintionsNode.createChild(SERVER_DEFINITION);
- sdNode.putString(NAME, serverDefinition.getName());
- sdNode.putString(VERSION, serverDefinition.getVersion());
- sdNode.putString(TYPE, serverDefinition.getType());
- sdNode.putString(LOCATION, serverDefinition.getLocation().getAbsolutePath());
- sdNode.putString(DESCRIPTION, serverDefinition.getDescription());
- sdNode.putBoolean(ENABLED, serverDefinition.isEnabled());
- }
+ IMemento serverDefinitionsNode = runtimePathNode.createChild(SERVER_DEFINITIONS);
+ List<ServerDefinition> definitions = runtimePath.getServerDefinitions();
+ putDefinitions(serverDefinitionsNode, definitions);
}
writer = new StringWriter();
memento.save(writer);
@@ -366,6 +393,29 @@
}
}
+ private void putDefinitions(IMemento serverDefintionsNode,
+ List<ServerDefinition> definitions) {
+ for (ServerDefinition serverDefinition:definitions) {
+ IMemento sdNode = serverDefintionsNode.createChild(SERVER_DEFINITION);
+ putServerDefinition(serverDefinition, sdNode);
+ IMemento includedNodes = sdNode.createChild(INCLUDED_DEFINITION);
+ for (ServerDefinition included:serverDefinition.getIncludedServerDefinitions()) {
+ IMemento includedNode = includedNodes.createChild(SERVER_DEFINITION);
+ putServerDefinition(included, includedNode);
+ }
+ }
+ }
+
+ private void putServerDefinition(ServerDefinition serverDefinition,
+ IMemento node) {
+ node.putString(NAME, serverDefinition.getName());
+ node.putString(VERSION, serverDefinition.getVersion());
+ node.putString(TYPE, serverDefinition.getType());
+ node.putString(LOCATION, serverDefinition.getLocation().getAbsolutePath());
+ node.putString(DESCRIPTION, serverDefinition.getDescription());
+ node.putBoolean(ENABLED, serverDefinition.isEnabled());
+ }
+
public List<RuntimePath> getRuntimePaths() {
if (runtimePaths == null) {
try {
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/EditRuntimePathDialog.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/EditRuntimePathDialog.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/EditRuntimePathDialog.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -17,7 +17,7 @@
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -45,7 +45,7 @@
private RuntimePath runtimePath;
private List<RuntimePath> runtimePaths;
- private CheckboxTableViewer tableViewer;
+ private CheckboxTreeViewer treeViewer;
public EditRuntimePathDialog(Shell parentShell, RuntimePath runtimePath) {
super(parentShell);
@@ -115,7 +115,7 @@
@Override
public void widgetSelected(SelectionEvent e) {
- RuntimeUIActivator.refreshRuntimes(getShell(), getRuntimePaths(), tableViewer, false,
15);
+ RuntimeUIActivator.refreshRuntimes(getShell(), getRuntimePaths(), treeViewer, false,
15);
}
});
@@ -133,8 +133,8 @@
refreshButton.setEnabled( (new File(pathText.getText()).isDirectory()) );
List<RuntimePath> runtimePaths = getRuntimePaths();
- tableViewer = RuntimeUIActivator.createRuntimeViewer(runtimePaths, contents, 100);
- tableViewer.addCheckStateListener(new ICheckStateListener() {
+ treeViewer = RuntimeUIActivator.createRuntimeViewer(runtimePaths, contents, 100);
+ treeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/SearchRuntimePathDialog.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/SearchRuntimePathDialog.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/SearchRuntimePathDialog.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -20,12 +20,12 @@
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ColumnViewerEditor;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.TableViewerEditor;
+import org.eclipse.jface.viewers.TreeViewerEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -38,7 +38,7 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.TreeItem;
import org.jboss.tools.runtime.core.RuntimeCoreActivator;
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
import org.jboss.tools.runtime.core.model.RuntimePath;
@@ -53,7 +53,7 @@
private List<RuntimePath> runtimePaths = new ArrayList<RuntimePath>();
private boolean running = true;
- private CheckboxTableViewer tableViewer;
+ private CheckboxTreeViewer treeViewer;
private boolean canceled;
private boolean needRefresh;
private Label foundRuntimesLabel;
@@ -115,8 +115,8 @@
// Only set for backwards compatibility
taskLabel = messageLabel;
- tableViewer = RuntimeUIActivator.createRuntimeViewer(runtimePaths, composite,
heightHint);
- tableViewer.addCheckStateListener(new ICheckStateListener() {
+ treeViewer = RuntimeUIActivator.createRuntimeViewer(runtimePaths, composite,
heightHint);
+ treeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
@@ -133,7 +133,7 @@
}
});
- ColumnViewerEditorActivationStrategy actSupport = new
ColumnViewerEditorActivationStrategy(tableViewer) {
+ ColumnViewerEditorActivationStrategy actSupport = new
ColumnViewerEditorActivationStrategy(treeViewer) {
protected boolean isEditorActivationEvent(
ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
@@ -142,7 +142,7 @@
}
};
- TableViewerEditor.create(tableViewer, actSupport,
+ TreeViewerEditor.create(treeViewer, actSupport,
ColumnViewerEditor.TABBING_HORIZONTAL
| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
| ColumnViewerEditor.TABBING_VERTICAL
@@ -209,21 +209,24 @@
private void refresh(String message) {
running = false;
- tableViewer.setInput(null);
+ treeViewer.setInput(null);
List<ServerDefinition> serverDefinitions =
getServerDefinitions(hideCreatedRuntimes.getSelection());
- tableViewer.setInput(serverDefinitions);
+ treeViewer.setInput(serverDefinitions);
for (ServerDefinition definition:serverDefinitions) {
- tableViewer.setChecked(definition, definition.isEnabled());
+ treeViewer.setChecked(definition, definition.isEnabled());
+ for (ServerDefinition included:definition.getIncludedServerDefinitions()) {
+ treeViewer.setChecked(included, included.isEnabled());
+ }
}
- TableItem[] tableItems = tableViewer.getTable().getItems();
- for (TableItem tableItem:tableItems) {
- Object data = tableItem.getData();
+ TreeItem[] treeItems = treeViewer.getTree().getItems();
+ for (TreeItem treeItem:treeItems) {
+ Object data = treeItem.getData();
if (data instanceof ServerDefinition) {
ServerDefinition serverDefinition = (ServerDefinition) data;
boolean exists = RuntimeUIActivator.runtimeExists(serverDefinition);
if (exists) {
- tableItem.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
- tableViewer.setChecked(serverDefinition, serverDefinition.isEnabled());
+ treeItem.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+ treeViewer.setChecked(serverDefinition, serverDefinition.isEnabled());
}
}
}
Modified: trunk/runtime/tests/org.jboss.tools.runtime.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/META-INF/MANIFEST.MF 2011-04-03
16:51:43 UTC (rev 30247)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/META-INF/MANIFEST.MF 2011-04-03
16:52:26 UTC (rev 30248)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %BundleName
Bundle-SymbolicName: org.jboss.tools.runtime.test;singleton:=true
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Require-Bundle: org.eclipse.core.runtime,
org.junit4,
org.jboss.tools.runtime,
Modified: trunk/runtime/tests/org.jboss.tools.runtime.test/pom.xml
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/pom.xml 2011-04-03 16:51:43 UTC (rev
30247)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/pom.xml 2011-04-03 16:52:26 UTC (rev
30248)
@@ -8,7 +8,7 @@
</parent>
<groupId>org.jboss.tools.runtime.tests</groupId>
<artifactId>org.jboss.tools.runtime.test</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/IRuntimeDetectionConstants.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/IRuntimeDetectionConstants.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/IRuntimeDetectionConstants.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -19,11 +19,11 @@
final static String JBOSS_42_HOME =
System.getProperty("jbosstools.test.jboss.home.4.2",
"E:\\JBossRuntimes\\jboss-4.2.3.GA");
- final static String JBOSS_51_HOME =
System.getProperty("jbosstools.test.jboss.home.5.1",
"E:\\JBossRuntimes\\jboss-5.1.0.GA");
+ final static String JBOSS_51_HOME =
System.getProperty("jbosstools.test.jboss.home.5.1",
"E:\\JBossRuntime2\\jboss-5.1.0.GA");
final static String SEAM_20_HOME =
System.getProperty("jbosstools.test.seam.2.0.1.GA.home",
"E:\\JBossRuntimes\\jboss-seam-2.0.1.GA");
- final static String SEAM_22_HOME =
System.getProperty("jbosstools.test.seam.2.2.0.GA.home",
"E:\\jboss-seam-2.2.1.Final");
+ final static String SEAM_22_HOME =
System.getProperty("jbosstools.test.seam.2.2.0.GA.home",
"E:\\JBossRuntime2\\jboss-seam-2.2.1.Final");
final static String EAP_43_HOME =
System.getProperty("jbosstools.test.eap.4.3.home",
"E:\\jboss-eap43_cp03");
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java 2011-04-03
16:51:43 UTC (rev 30247)
+++
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java 2011-04-03
16:52:26 UTC (rev 30248)
@@ -15,17 +15,29 @@
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeType;
import org.eclipse.wst.server.core.ServerCore;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.tools.runtime.IJBossRuntimePluginConstants;
import org.jboss.tools.runtime.core.JBossRuntimeLocator;
import org.jboss.tools.runtime.core.RuntimeCoreActivator;
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
@@ -37,13 +49,19 @@
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
/**
*
* @author snjeza
*
*/
-public class RuntimeDetectionTest {
+public class RuntimeDetectionTest implements IJBossRuntimePluginConstants {
private final static String seamVersionAttributeName = "Seam-Version";
@BeforeClass
@@ -289,4 +307,79 @@
assertTrue("runtimes.length\nExpected: 3\nWas: " + runtimes.length,
runtimes.length == 3);
}
+
+ @Test
+ public void testIncludedDefinitions() {
+ for (ServerDefinition
serverDefinition:RuntimeUIActivator.getDefault().getServerDefinitions()){
+ String type = serverDefinition.getType();
+ if (EAP.equals(type)) {
+ assertTrue("EAP has to include server definitions",
serverDefinition.getIncludedServerDefinitions().size() > 0);
+ for(ServerDefinition included:serverDefinition.getIncludedServerDefinitions()) {
+ assertTrue("Invalid parent definition", included.getParent() ==
serverDefinition);
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testSavePreferences() throws Exception {
+ // saves preferences
+ Bundle bundle = Platform.getBundle(RuntimeUIActivator.PLUGIN_ID);
+ bundle.stop();
+ // loads preferences
+ bundle.start();
+ // calls tests again
+ testServerDefinitions();
+ testIncludedDefinitions();
+ testRuntimePaths();
+ testRuntimeDetectors();
+ testLocations();
+ testSeamRuntimes();
+ testWtpRuntimes();
+ testSeam22();
+ testSeam22Location();
+ }
+
+ @Test
+ public void testOldWorkspace() throws Exception {
+ String runtimes = ConfigurationScope.INSTANCE.getNode(
+ RuntimeUIActivator.PLUGIN_ID).get(
+ RuntimeUIActivator.RUNTIME_PATHS, null);
+ // removes version and included definitions
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ Document doc = factory.newDocumentBuilder().parse(new InputSource(new
StringReader(runtimes)));
+ Element runtimePaths = (Element)
doc.getElementsByTagName(RuntimeUIActivator.RUNTIME_PATHS).item(0);
+ runtimePaths.removeAttribute(RuntimeUIActivator.PREFERENCES_VERSION);
+ removeIncluded(doc);
+ runtimes = serialize(doc);
+ // restarts the bundle
+ Bundle bundle = Platform.getBundle(RuntimeUIActivator.PLUGIN_ID);
+ bundle.stop();
+ bundle.start();
+ // saves preferences
+ ConfigurationScope.INSTANCE.getNode(RuntimeUIActivator.PLUGIN_ID).put(
+ RuntimeUIActivator.RUNTIME_PATHS, runtimes);
+ // calls tests again
+ testIncludedDefinitions();
+ testServerDefinitions();
+ }
+
+ private void removeIncluded(Node node) {
+ if (node.getNodeType() == Node.ELEMENT_NODE
+ && node.getNodeName().equals("included")) {
+ node.getParentNode().removeChild(node);
+ } else {
+ NodeList list = node.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ removeIncluded(list.item(i));
+ }
+ }
+ }
+
+ private String serialize(Document doc) throws TransformerException {
+ StringWriter stringWriter = new StringWriter();
+ Transformer serializer = TransformerFactory.newInstance().newTransformer();
+ serializer.transform(new DOMSource(doc), new StreamResult(stringWriter));
+ return stringWriter.toString();
+ }
}