Author: snjeza
Date: 2010-11-19 08:56:17 -0500 (Fri, 19 Nov 2010)
New Revision: 26765
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeLocator.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/ServerDefinition.java
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/JbpmHandler.java
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/preferences/RuntimeDialog.java
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimePreferencePage.java
Log:
JBIDE-7524 JBoss Tools Runtimes improvements
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeLocator.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeLocator.java 2010-11-19
13:48:42 UTC (rev 26764)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeLocator.java 2010-11-19
13:56:17 UTC (rev 26765)
@@ -60,10 +60,16 @@
if (!JBossServerType.UNKNOWN.equals(serverBean.getType())) {
serverDefinitions.add(new ServerDefinition(serverBean));
+ if (monitor.isCanceled()) {
+ return serverDefinitions;
+ }
} else {
String seamVersion = getSeamVersionFromManifest(root.getAbsolutePath());
if (seamVersion != null) {
serverDefinitions.add(new ServerDefinition(root.getName(), seamVersion, SEAM,
root.getAbsoluteFile()));
+ if (monitor.isCanceled()) {
+ return serverDefinitions;
+ }
} else {
String[] files = root.list(new FilenameFilter() {
@@ -83,6 +89,9 @@
droolsFound = true;
}
}
+ if (monitor.isCanceled()) {
+ return serverDefinitions;
+ }
boolean jbpmFound = false;
if (!droolsFound) {
boolean isJBPM = isValidJbpmInstallation(root.getAbsolutePath());
@@ -97,6 +106,9 @@
jbpmFound = true;
}
}
+ if (monitor.isCanceled()) {
+ return serverDefinitions;
+ }
if (!droolsFound && !jbpmFound) {
children = root.listFiles();
}
@@ -106,6 +118,9 @@
} else {
children = File.listRoots();
}
+ if (monitor.isCanceled()) {
+ return serverDefinitions;
+ }
if (depth == 0) {
return serverDefinitions;
}
@@ -140,6 +155,25 @@
}
public static String getSeamVersionFromManifest(String seamHome) {
+ File seamHomeFolder = new File(seamHome);
+ if (seamHomeFolder == null || !seamHomeFolder.isDirectory()) {
+ return null;
+ }
+ String[] seamFiles = seamHomeFolder.list(new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+ if ("seam-gen".equals(name)) {
+ return true;
+ }
+ if ("examples".equals(name)) {
+ return true;
+ }
+ return false;
+ }
+ });
+ if (seamFiles == null || seamFiles.length != 2) {
+ return null;
+ }
File jarFile = new File(seamHome, "lib/" + seamJarName);
if(!jarFile.isFile()) {
jarFile = new File(seamHome, seamJarName);
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java 2010-11-19
13:48:42 UTC (rev 26764)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java 2010-11-19
13:56:17 UTC (rev 26765)
@@ -44,6 +44,7 @@
public class JBossRuntimeStartup implements IStartup, IJBossRuntimePluginConstants {
+ private static IJBossRuntimePersistanceHandler[] jBossRuntimePersistanceHandler = null;
public static interface IJBossRuntimePersistanceHandler {
public void initializeRuntimes(List<ServerDefinition> serverDefinitions);
public void importRuntimes();
@@ -51,12 +52,15 @@
}
public static IJBossRuntimePersistanceHandler[] getPersistanceHandlers() {
- return new IJBossRuntimePersistanceHandler[] {
- new JbpmHandler(),
- new DroolsHandler(),
- new JBossASHandler(),
- new SeamHandler()
- };
+ if (jBossRuntimePersistanceHandler == null) {
+ jBossRuntimePersistanceHandler = new IJBossRuntimePersistanceHandler[] {
+ new JbpmHandler(),
+ new DroolsHandler(),
+ new JBossASHandler(),
+ new SeamHandler()
+ };
+ }
+ return jBossRuntimePersistanceHandler;
}
private List<ServerDefinition> serverDefinitions = new
ArrayList<ServerDefinition>();
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/ServerDefinition.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/ServerDefinition.java 2010-11-19
13:48:42 UTC (rev 26764)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/ServerDefinition.java 2010-11-19
13:56:17 UTC (rev 26765)
@@ -13,7 +13,12 @@
import java.io.File;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBean;
+import org.jboss.tools.runtime.handlers.DroolsHandler;
+import org.jboss.tools.runtime.handlers.JbpmHandler;
+import org.jboss.tools.runtime.handlers.SeamHandler;
+import static org.jboss.tools.runtime.IJBossRuntimePluginConstants.*;
+
/**
* @author Snjeza
*
@@ -23,6 +28,7 @@
private String name;
private String version;
private String type;
+ private String description;
private File location;
private boolean enabled = true;
@@ -33,6 +39,7 @@
this.version = version;
this.type = type;
this.location = location;
+ this.description = null;
}
/**
@@ -57,17 +64,23 @@
public void setVersion(String version) {
this.version = version;
}
+
public String getType() {
return type;
}
+
public void setType(String type) {
this.type = type;
+ this.description = "";
}
+
public File getLocation() {
return location;
}
+
public void setLocation(File location) {
this.location = location;
+ this.description = "";
}
@Override
@@ -127,5 +140,41 @@
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
+
+ public String getDescription() {
+ if (type == null || location == null) {
+ return "";
+ }
+ if (description == null || description.length() == 0) {
+ StringBuilder builder = new StringBuilder();
+ if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || EWP.equals(type)) {
+ String includeSeam = SeamHandler.includeSeam(this);
+ append(builder, includeSeam);
+ }
+ if (SOA_P.equals(type)) {
+ String includeDrools = DroolsHandler.includeDrools(this);
+ append(builder, includeDrools);
+ String includeJbpm = JbpmHandler.includeJbpm(this);
+ append(builder, includeJbpm);
+ }
+ description = builder.toString();
+ }
+ return description;
+ }
+
+ private void append(StringBuilder builder, String string) {
+ if (string != null && string.length() > 0) {
+ if (builder.toString().length() == 0) {
+ builder.append("Includes ");
+ } else {
+ builder.append(", ");
+ }
+ builder.append(string);
+ }
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
}
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 2010-11-19
13:48:42 UTC (rev 26764)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java 2010-11-19
13:56:17 UTC (rev 26765)
@@ -66,6 +66,18 @@
return false;
}
+ public static String includeDrools(ServerDefinition serverDefinition) {
+ StringBuilder builder = new StringBuilder();
+ File droolsRoot = serverDefinition.getLocation(); //$NON-NLS-1$
+ if (droolsRoot.isDirectory()) {
+ builder.append("Drools");
+ if (serverDefinition.getVersion() != null &&
serverDefinition.getVersion().length() > 0) {
+ builder.append(" ");
+ builder.append(serverDefinition.getVersion());
+ }
+ }
+ return builder.toString();
+ }
public void importRuntimes() {
// TODO Auto-generated method stub
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 2010-11-19
13:48:42 UTC (rev 26764)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JbpmHandler.java 2010-11-19
13:56:17 UTC (rev 26765)
@@ -111,6 +111,19 @@
}
}
+ public static String includeJbpm(ServerDefinition serverDefinition) {
+ StringBuilder builder = new StringBuilder();
+ File jbpmRoot = new File(serverDefinition.getLocation(),"jbpm-jpdl");
//$NON-NLS-1$
+ if (jbpmRoot.isDirectory()) {
+ String version = JBossRuntimeLocator.JBPM3;
+ if (JBossRuntimeLocator.isJbpm4(serverDefinition.getLocation().getAbsolutePath())) {
+ version = JBossRuntimeLocator.JBPM4;
+ }
+ builder.append(version);
+ }
+ return builder.toString();
+ }
+
public void importRuntimes() {
String jbpms = Activator.getDefault().getPreferenceStore().getString(Activator.JBPMS);
if (jbpms != null && jbpms.trim().length() > 0) {
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 2010-11-19
13:48:42 UTC (rev 26764)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2010-11-19
13:56:17 UTC (rev 26765)
@@ -70,6 +70,7 @@
seamGenBuildPath = getSeamGenBuildPath(SEAM_2_0_HOME_CP,
SEAM_2_0_HOME_CONFIGURATION_CP);
seamVersion = getSeamVersion(seamGenBuildPath);
addSeam2(map, seamGenBuildPath, seamVersion);
+ SeamRuntimeManager.getInstance().save();
}
private static void addSeam1(Map<String, SeamRuntime> map,
@@ -104,22 +105,6 @@
}
}
- private static SeamVersion getSeamVersion(String seamGenBuildPath) {
- if (seamGenBuildPath == null || seamGenBuildPath.trim().length() <= 0) {
- return null;
- }
- String fullVersion = SeamUtil.getSeamVersionFromManifest(seamGenBuildPath);
- if (fullVersion == null) {
- return null;
- }
- String version = fullVersion.substring(0,3);
- SeamVersion seamVersion = null;
- if (version != null) {
- seamVersion = SeamVersion.findByString(version);
- }
- return seamVersion;
- }
-
private static void addSeam(Map<String, SeamRuntime> map, String
seamPath,SeamVersion seamVersion, String name) {
if (!seamExists(seamPath)) {
File seamFolder = new File(seamPath);
@@ -134,20 +119,6 @@
}
}
- /**
- * @param seamPath
- * @return
- */
- private static boolean seamExists(String seamPath) {
- SeamRuntime[] seamRuntimes = SeamRuntimeManager.getInstance().getRuntimes();
- for (SeamRuntime sr:seamRuntimes) {
- if (seamPath != null && seamPath.equals(sr.getHomeDir())) {
- return true;
- }
- }
- return false;
- }
-
private static String getSeamGenBuildPath(String seamHomePath,
String seamHomePathConfiguration) {
try {
@@ -184,4 +155,52 @@
}
+ public static String includeSeam(ServerDefinition serverDefinition) {
+ StringBuilder builder = new StringBuilder();
+ 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())
{
+ SeamVersion seamVersion = getSeamVersion(seamFile.getAbsolutePath());
+ if (seamVersion != null) {
+ if (builder.toString().length() > 0) {
+ builder.append(", ");
+ }
+ builder.append("Seam ");
+ builder.append(seamVersion);
+ }
+ }
+ }
+ return builder.toString();
+ }
+
+ public static SeamVersion getSeamVersion(String seamGenBuildPath) {
+ if (seamGenBuildPath == null || seamGenBuildPath.trim().length() <= 0) {
+ return null;
+ }
+ String fullVersion = SeamUtil.getSeamVersionFromManifest(seamGenBuildPath);
+ if (fullVersion == null) {
+ return null;
+ }
+ String version = fullVersion.substring(0,3);
+ SeamVersion seamVersion = null;
+ if (version != null) {
+ seamVersion = SeamVersion.findByString(version);
+ }
+ return seamVersion;
+ }
+
+ /**
+ * @param seamPath
+ * @return
+ */
+ public static boolean seamExists(String seamPath) {
+ SeamRuntime[] seamRuntimes = SeamRuntimeManager.getInstance().getRuntimes();
+ for (SeamRuntime sr:seamRuntimes) {
+ if (seamPath != null && seamPath.equals(sr.getHomeDir())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimeDialog.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimeDialog.java 2010-11-19
13:48:42 UTC (rev 26764)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimeDialog.java 2010-11-19
13:56:17 UTC (rev 26765)
@@ -45,7 +45,7 @@
Composite contents = new Composite(area, SWT.NONE);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 400;
- gd.widthHint = 500;
+ gd.widthHint = 700;
contents.setLayoutData(gd);
contents.setLayout(new GridLayout());
getShell().setText("JBoss Runtimes");
@@ -64,8 +64,8 @@
table.setHeaderVisible(true);
table.setLinesVisible(true);
- String[] columnNames = new String[] { "Name", "Version",
"Type", "Location"};
- int[] columnWidths = new int[] { 140, 50, 50, 245};
+ String[] columnNames = new String[] { "Name", "Version",
"Type", "Location", "Description"};
+ int[] columnWidths = new int[] { 140, 50, 50, 245, 200};
for (int i = 0; i < columnNames.length; i++) {
TableColumn tc = new TableColumn(table, SWT.LEFT);
@@ -121,6 +121,9 @@
return definition.getLocation().getAbsolutePath();
}
}
+ if (columnIndex == 4) {
+ return definition.getDescription();
+ }
}
return null;
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimePreferencePage.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimePreferencePage.java 2010-11-19
13:48:42 UTC (rev 26764)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimePreferencePage.java 2010-11-19
13:56:17 UTC (rev 26765)
@@ -10,16 +10,12 @@
************************************************************************************/
package org.jboss.tools.runtime.preferences;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -30,6 +26,7 @@
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.layout.PixelConverter;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -47,23 +44,18 @@
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.internal.wizards.preferences.PreferencesExportWizard;
import org.eclipse.ui.internal.wizards.preferences.PreferencesImportWizard;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.internal.IMemento;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-import org.eclipse.wst.server.core.internal.XMLMemento;
import org.jboss.tools.runtime.Activator;
import org.jboss.tools.runtime.JBossRuntimeLocator;
import org.jboss.tools.runtime.JBossRuntimeStartup;
-import org.jboss.tools.runtime.ServerDefinition;
import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
-import org.jboss.tools.runtime.handlers.JbpmHandler;
+import org.jboss.tools.runtime.ServerDefinition;
/**
* @author Snjeza
@@ -72,6 +64,7 @@
public class RuntimePreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
+ public static String ID =
"org.jboss.tools.runtime.preferences.RuntimePreferencePage";
private static final String LASTPATH = "lastPath";
public static final String SEAM_PREFERENCES_ID =
"org.jboss.tools.common.model.ui.seam"; //$NON-NLS-1$
public static final String WTP_PREFERENCES_ID =
"org.eclipse.wst.server.ui.runtime.preferencePage"; //$NON-NLS-1$
@@ -99,10 +92,10 @@
composite.setLayout(layout);
- createLink(composite, "See <a>WTP Runtime</a>",
WTP_PREFERENCES_ID);
- createLink(composite, "See <a>Seam Runtime</a>",
SEAM_PREFERENCES_ID);
- createLink(composite, "See <a>Drools Runtime</a>",
DROOLS_PREFERENCES_ID);
- createLink(composite, "See <a>JBPM Runtime</a>",
JBPM_PREFERENCES_ID);
+ createLink(composite, "See <a>WTP Runtimes</a>",
WTP_PREFERENCES_ID);
+ createLink(composite, "See <a>Seam Runtimes</a>",
SEAM_PREFERENCES_ID);
+ createLink(composite, "See <a>Drools Runtimes</a>",
DROOLS_PREFERENCES_ID);
+ createLink(composite, "See <a>JBPM Runtimes</a>",
JBPM_PREFERENCES_ID);
new Label(composite, SWT.NONE);
@@ -159,9 +152,6 @@
dialog.create();
dialog.open();
}
-
- private void exportServers() {
- }
private void importRuntimes() {
PreferencesImportWizard wizard = new PreferencesImportWizard();
@@ -174,6 +164,7 @@
for( int i = 0; i < importHandlers.length; i++ ) {
importHandlers[i].importRuntimes();
}
+ refreshPreferencePage();
}
}
@@ -265,10 +256,18 @@
}
JBossRuntimeStartup runtimeStartup = new JBossRuntimeStartup();
runtimeStartup.initializeRuntimes(serverDefinitions);
+ refreshPreferencePage();
}
}
}
+
+ private void refreshPreferencePage() {
+ getShell().close();
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(shell, ID,
null, null);
+ preferenceDialog.open();
+ }
/**
* Returns a width hint for a button control.