Author: snjeza
Date: 2011-01-07 15:57:52 -0500 (Fri, 07 Jan 2011)
New Revision: 27999
Added:
trunk/runtime/features/org.jboss.tools.runtime.core.feature/.project
trunk/runtime/features/org.jboss.tools.runtime.core.feature/build.properties
trunk/runtime/features/org.jboss.tools.runtime.core.feature/feature.properties
trunk/runtime/features/org.jboss.tools.runtime.core.feature/feature.xml
trunk/runtime/features/org.jboss.tools.runtime.core.feature/license.html
trunk/runtime/features/org.jboss.tools.runtime.core.feature/pom.xml
trunk/runtime/plugins/org.jboss.tools.runtime.core/.classpath
trunk/runtime/plugins/org.jboss.tools.runtime.core/.project
trunk/runtime/plugins/org.jboss.tools.runtime.core/.settings/
trunk/runtime/plugins/org.jboss.tools.runtime.core/.settings/org.eclipse.jdt.core.prefs
trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/
trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF
trunk/runtime/plugins/org.jboss.tools.runtime.core/about.html
trunk/runtime/plugins/org.jboss.tools.runtime.core/about.ini
trunk/runtime/plugins/org.jboss.tools.runtime.core/about.mappings
trunk/runtime/plugins/org.jboss.tools.runtime.core/about.properties
trunk/runtime/plugins/org.jboss.tools.runtime.core/build.properties
trunk/runtime/plugins/org.jboss.tools.runtime.core/jboss_about.png
trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.properties
trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml
trunk/runtime/plugins/org.jboss.tools.runtime.core/pom.xml
trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/
trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/runtimeDetectors.exsd
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/JBossRuntimeLocator.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/
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/RuntimePath.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/.classpath
trunk/runtime/plugins/org.jboss.tools.runtime.ui/.project
trunk/runtime/plugins/org.jboss.tools.runtime.ui/.settings/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/.settings/org.eclipse.jdt.core.prefs
trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF
trunk/runtime/plugins/org.jboss.tools.runtime.ui/build.properties
trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/jboss.gif
trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/xpl/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/xpl/complete_tsk.gif
trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/xpl/error_tsk.gif
trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/xpl/incomplete_tsk.gif
trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.properties
trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.xml
trunk/runtime/plugins/org.jboss.tools.runtime.ui/pom.xml
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/
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/RuntimeLabelProvider.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeScanner.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/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/AutoResizeTableLayout.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/RuntimePathEditingSupport.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.ui/src/org/jboss/tools/runtime/ui/preferences/
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/JBossRuntimePreferencesInitializer.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
trunk/runtime/plugins/org.jboss.tools.runtime/about.ini
trunk/runtime/plugins/org.jboss.tools.runtime/about.mappings
trunk/runtime/plugins/org.jboss.tools.runtime/about.properties
Removed:
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/ServerDefinition.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
Modified:
trunk/runtime/features/pom.xml
trunk/runtime/plugins/org.jboss.tools.runtime/.classpath
trunk/runtime/plugins/org.jboss.tools.runtime/.settings/org.eclipse.jdt.core.prefs
trunk/runtime/plugins/org.jboss.tools.runtime/META-INF/MANIFEST.MF
trunk/runtime/plugins/org.jboss.tools.runtime/build.properties
trunk/runtime/plugins/org.jboss.tools.runtime/plugin.properties
trunk/runtime/plugins/org.jboss.tools.runtime/plugin.xml
trunk/runtime/plugins/org.jboss.tools.runtime/pom.xml
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/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/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/JBossRuntimePreferencesInitializer.java
trunk/runtime/plugins/pom.xml
Log:
JBIDE-7527 Automatic runtime detection
Added: trunk/runtime/features/org.jboss.tools.runtime.core.feature/.project
===================================================================
--- trunk/runtime/features/org.jboss.tools.runtime.core.feature/.project
(rev 0)
+++ trunk/runtime/features/org.jboss.tools.runtime.core.feature/.project 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.runtime.core.feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
Added: trunk/runtime/features/org.jboss.tools.runtime.core.feature/build.properties
===================================================================
--- trunk/runtime/features/org.jboss.tools.runtime.core.feature/build.properties
(rev 0)
+++
trunk/runtime/features/org.jboss.tools.runtime.core.feature/build.properties 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,3 @@
+bin.includes = feature.xml,\
+ feature.properties,\
+ license.html
Added: trunk/runtime/features/org.jboss.tools.runtime.core.feature/feature.properties
===================================================================
--- trunk/runtime/features/org.jboss.tools.runtime.core.feature/feature.properties
(rev 0)
+++
trunk/runtime/features/org.jboss.tools.runtime.core.feature/feature.properties 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,55 @@
+###############################################################################
+# Copyright (c) 2009-2010 JBoss by Red Hat and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+#
http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# JBoss by Red Hat - Initial implementation.
+##############################################################################
+# feature.properties
+# contains externalized strings for feature.xml
+# "%foo" in feature.xml corresponds to the key "foo" in this file
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file should be translated.
+
+# "featureName" property - name of the feature
+featureName=JBoss Runtime Detection Core
+
+# "providerName" property - name of the company that provides the feature
+providerName=JBoss by Red Hat
+
+# "updateSiteName" property - label for the update/discovery sites
+updateSiteName=JBoss Developer Studio Updates
+JBossToolsUpdatesSiteName=JBoss Tools Updates
+
+# "description" property - description of the feature
+description=Project Examples
+
+# "copyright" property - text of the "Feature Update Copyright"
+copyright=Copyright (c) 2008-2010 JBoss by Red Hat and others.\nAll rights reserved. This
program and the accompanying materials\n
+are made available under the terms of the Eclipse Public License v1.0\n\
+which accompanies this distribution, and is available at\n\
+http\://www.eclipse.org/legal/epl-v10.html\n\
+\n\
+Contributors\:\n\
+JBoss by Red Hat - Initial implementation.\n
+ ############### end of copyright property ####################################
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# START NON-TRANSLATABLE
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=Red Hat, Inc. licenses these features and plugins to you under \
+certain open source licenses (or aggregations of such licenses), which \
+in a particular case may include the Eclipse Public License, the GNU \
+Lesser General Public License, and/or certain other open source \
+licenses. For precise licensing details, consult the corresponding \
+source code, or contact Red Hat Legal Affairs, 1801 Varsity Drive, \
+Raleigh NC 27606 USA.
+# END NON-TRANSLATABLE
+########### end of license property ##########################################
Added: trunk/runtime/features/org.jboss.tools.runtime.core.feature/feature.xml
===================================================================
--- trunk/runtime/features/org.jboss.tools.runtime.core.feature/feature.xml
(rev 0)
+++ trunk/runtime/features/org.jboss.tools.runtime.core.feature/feature.xml 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.jboss.tools.runtime.core.feature"
+ label="%featureName"
+ version="1.0.0.qualifier"
+ provider-name="%providerName"
+ plugin="org.jboss.tools.runtime.core">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <plugin
+ id="org.jboss.tools.runtime.core"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.jboss.tools.runtime.ui"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
Added: trunk/runtime/features/org.jboss.tools.runtime.core.feature/license.html
===================================================================
--- trunk/runtime/features/org.jboss.tools.runtime.core.feature/license.html
(rev 0)
+++ trunk/runtime/features/org.jboss.tools.runtime.core.feature/license.html 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+
+<body>
+<p>Red Hat, Inc. licenses these features and plugins to you under
+certain open source licenses (or aggregations of such licenses), which
+in a particular case may include the Eclipse Public License, the GNU
+Lesser General Public License, and/or certain other open source
+licenses. For precise licensing details, consult the corresponding
+source code, or contact Red Hat Legal Affairs, 1801 Varsity Drive,
+Raleigh NC 27606 USA.
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/runtime/features/org.jboss.tools.runtime.core.feature/pom.xml
===================================================================
--- trunk/runtime/features/org.jboss.tools.runtime.core.feature/pom.xml
(rev 0)
+++ trunk/runtime/features/org.jboss.tools.runtime.core.feature/pom.xml 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,14 @@
+<project
+xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>org.jboss.tools.parent.pom</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>org.jboss.tools.runtime.core.feature</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-feature</packaging>
+</project>
Modified: trunk/runtime/features/pom.xml
===================================================================
--- trunk/runtime/features/pom.xml 2011-01-07 20:55:29 UTC (rev 27998)
+++ trunk/runtime/features/pom.xml 2011-01-07 20:57:52 UTC (rev 27999)
@@ -12,6 +12,7 @@
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
+ <module>org.jboss.tools.runtime.core.feature</module>
<module>org.jboss.tools.runtime.feature</module>
</modules>
</project>
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/.classpath
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/.classpath 2011-01-07 20:55:29 UTC (rev
27998)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/.classpath 2011-01-07 20:57:52 UTC (rev
27999)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/.settings/org.eclipse.jdt.core.prefs 2011-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/.settings/org.eclipse.jdt.core.prefs 2011-01-07
20:57:52 UTC (rev 27999)
@@ -1,7 +1,8 @@
-#Thu Dec 04 23:27:23 CET 2008
+#Thu Dec 02 21:41:17 CET 2010
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.6
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/META-INF/MANIFEST.MF 2011-01-07 20:55:29
UTC (rev 27998)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/META-INF/MANIFEST.MF 2011-01-07 20:57:52
UTC (rev 27999)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %BundleName
Bundle-SymbolicName: org.jboss.tools.runtime;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.2.0.qualifier
Bundle-Activator: org.jboss.tools.runtime.Activator
Bundle-Vendor: %BundleVendor
Require-Bundle: org.eclipse.core.runtime,
@@ -18,9 +18,13 @@
org.eclipse.datatools.connectivity;visibility:=reexport,
org.eclipse.datatools.connectivity.db.generic,
org.jboss.tools.common,
+ org.jboss.tools.runtime.core,
org.jboss.ide.eclipse.as.core,
org.jboss.tools.jbpm.common
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
+Export-Package: org.jboss.tools.runtime,
+ org.jboss.tools.runtime.handlers,
+ org.jboss.tools.runtime.preferences
Added: trunk/runtime/plugins/org.jboss.tools.runtime/about.ini
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/about.ini (rev
0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/about.ini 2011-01-07 20:57:52 UTC (rev
27999)
@@ -0,0 +1,27 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+# test
+# Property "aboutText" contains blurb for "About" dialog
(translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=jboss_about.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (not translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which
the
+# welcome page is to be opened.
+# optional
+
+
+
Added: trunk/runtime/plugins/org.jboss.tools.runtime/about.mappings
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/about.mappings
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/about.mappings 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -0,0 +1,5 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
Added: trunk/runtime/plugins/org.jboss.tools.runtime/about.properties
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/about.properties
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/about.properties 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -0,0 +1,2 @@
+blurb=JBoss Runtime Initializer\n\nVersion\: {featureVersion}\n\n(c) Copyright JBoss by
Red Hat, contributors and others 2004 - 2010. All rights reserved.\nVisit
http\://jboss.org/tools
+
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/build.properties
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/build.properties 2011-01-07 20:55:29 UTC
(rev 27998)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/build.properties 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -5,4 +5,7 @@
plugin.xml,\
plugin.properties,\
about.html,\
- icons/
+ about.ini,\
+ about.mappings,\
+ about.properties,\
+ jboss_about.png
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/plugin.properties
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/plugin.properties 2011-01-07 20:55:29
UTC (rev 27998)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/plugin.properties 2011-01-07 20:57:52
UTC (rev 27999)
@@ -1,5 +1,3 @@
#Properties file for org.jboss.tools.runtime
BundleVendor = JBoss by Red Hat
-BundleName = JBoss Runtime Initializer
-JBoss_Runtimes = JBoss Runtimes
-ImportExportJBossRuntimes = Import / Export JBoss Runtimes
\ No newline at end of file
+BundleName = JBoss Runtime Initializer
\ No newline at end of file
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/plugin.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/plugin.xml 2011-01-07 20:55:29 UTC (rev
27998)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/plugin.xml 2011-01-07 20:57:52 UTC (rev
27999)
@@ -13,15 +13,6 @@
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.jboss.tools.runtime.preferences.JBossRuntimePreferencesInitializer"/>
</extension>
-
- <extension
- point="org.eclipse.ui.preferencePages">
- <page
- category="org.jboss.tools.common.model.ui.MainPreferencePage"
- class="org.jboss.tools.runtime.preferences.RuntimePreferencePage"
- id="org.jboss.tools.runtime.preferences.RuntimePreferencePage"
- name="%JBoss_Runtimes"/>
- </extension>
<extension
point="org.eclipse.ui.preferenceTransfer">
@@ -70,4 +61,43 @@
</extension>
-->
+ <extension
+ point="org.jboss.tools.runtime.core.runtimeDetectors">
+ <runtimeDetector
+ id="org.jboss.tools.runtime.handlers.JBossASHandler"
+ name="JBoss AS"
+ class="org.jboss.tools.runtime.handlers.JBossASHandler"
+ preferenceId="org.eclipse.wst.server.ui.runtime.preferencePage"
+ priority="100"/>
+ </extension>
+
+ <extension
+ point="org.jboss.tools.runtime.core.runtimeDetectors">
+ <runtimeDetector
+ id="org.jboss.tools.runtime.handlers.DroolsHandler"
+ name="Drools"
+ class="org.jboss.tools.runtime.handlers.DroolsHandler"
+
preferenceId="org.drools.eclipse.preferences.DroolsRuntimesPreferencePage"
+ priority="300"/>
+ </extension>
+
+ <extension
+ point="org.jboss.tools.runtime.core.runtimeDetectors">
+ <runtimeDetector
+ id="org.jboss.tools.runtime.handlers.JbpmHandler"
+ name="jBPM"
+ class="org.jboss.tools.runtime.handlers.JbpmHandler"
+ preferenceId="org.jboss.tools.jbpm.locations"
+ priority="400"/>
+ </extension>
+
+ <extension
+ point="org.jboss.tools.runtime.core.runtimeDetectors">
+ <runtimeDetector
+ id="org.jboss.tools.runtime.handlers.SeamHandler"
+ name="Seam"
+ class="org.jboss.tools.runtime.handlers.SeamHandler"
+ preferenceId="org.jboss.tools.common.model.ui.seam"
+ priority="200"/>
+ </extension>
</plugin>
Modified: trunk/runtime/plugins/org.jboss.tools.runtime/pom.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime/pom.xml 2011-01-07 20:55:29 UTC (rev
27998)
+++ trunk/runtime/plugins/org.jboss.tools.runtime/pom.xml 2011-01-07 20:57:52 UTC (rev
27999)
@@ -9,6 +9,6 @@
</parent>
<groupId>org.jboss.tools</groupId>
<artifactId>org.jboss.tools.runtime</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
Deleted:
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 2011-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeLocator.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.runtime;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
-import org.jboss.ide.eclipse.as.core.server.bean.ServerBean;
-import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
-
-public class JBossRuntimeLocator implements IJBossRuntimePluginConstants {
-
- public static final String JBPM3 = "jBPM3";
-
- public static final String JBPM4 = "jBPM4";
- private final static String seamJarName = "jboss-seam.jar";
- private final static String seamVersionAttributeName = "Seam-Version";
-
- public JBossRuntimeLocator() {
- }
-
- public List<ServerDefinition> searchForRuntimes(String path, IProgressMonitor
monitor) {
- return searchForRuntimes(new Path(path), monitor);
- }
-
- public List<ServerDefinition> searchForRuntimes(IPath path, IProgressMonitor
monitor) {
- ServerBeanLoader loader = new ServerBeanLoader();
- List<ServerDefinition> serverDefinitions = new
ArrayList<ServerDefinition>();
- return searchForRuntimes(serverDefinitions, path, loader, 4, monitor);
- }
-
- private List<ServerDefinition> searchForRuntimes(List<ServerDefinition>
serverDefinitions, IPath path, ServerBeanLoader loader, int depth, IProgressMonitor
monitor) {
- if (monitor.isCanceled()) {
- return serverDefinitions;
- }
- File[] children = null;
- if (path != null) {
- monitor.setTaskName("Searching " + path.toOSString());
- }
- if (path != null) {
- File root = path.toFile();
- ServerBean serverBean = loader.loadFromLocation(root);
-
- 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() {
-
- public boolean accept(File dir, String name) {
- if (name.startsWith("drools-api") &&
name.endsWith(".jar") ) {
- return true;
- }
- return false;
- }
- });
- boolean droolsFound = false;
- if (files != null && files.length > 0) {
- String version = getImplementationVersion(root,files[0]);
- if (version != null) {
- version = version.substring(0,3);
- serverDefinitions.add(new ServerDefinition(root.getName(), version, DROOLS,
root.getAbsoluteFile()));
- droolsFound = true;
- }
- }
- if (monitor.isCanceled()) {
- return serverDefinitions;
- }
- boolean jbpmFound = false;
- if (!droolsFound) {
- boolean isJBPM = isValidJbpmInstallation(root.getAbsolutePath());
- if (isJBPM) {
- String version = "unknown";
- if (isJbpm3(root.getAbsolutePath())) {
- version = JBPM3;
- } else if (isJbpm4(root.getAbsolutePath())) {
- version = JBPM4;
- }
- serverDefinitions.add(new ServerDefinition(root.getName(), version, JBPM,
root.getAbsoluteFile()));
- jbpmFound = true;
- }
- }
- if (monitor.isCanceled()) {
- return serverDefinitions;
- }
- if (!droolsFound && !jbpmFound) {
- children = root.listFiles();
- }
- }
-
- }
- } else {
- children = File.listRoots();
- }
- if (monitor.isCanceled()) {
- return serverDefinitions;
- }
- if (depth == 0) {
- return serverDefinitions;
- }
- if( children != null ) {
- for( int i = 0; i < children.length; i++ ) {
- if( children[i].isDirectory()) {
- searchForRuntimes(serverDefinitions, new Path(children[i].getAbsolutePath()),
loader, --depth, monitor);
- }
- }
- }
- return serverDefinitions;
- }
-
- /**
- * @param dir
- * @param string
- * @return
- */
- private String getImplementationVersion(File dir, String file) {
- File jarFile = new File(dir, file);
- if(!jarFile.isFile()) {
- return null;
- }
- try {
- JarFile jar = new JarFile(jarFile);
- Attributes attributes = jar.getManifest().getMainAttributes();
- String version = attributes.getValue("Implementation-Version");
- return version;
- } catch (IOException e) {
- return null;
- }
- }
-
- 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);
- if(!jarFile.isFile()) {
- return null;
- }
- }
- try {
- JarFile jar = new JarFile(jarFile);
- Attributes attributes = jar.getManifest().getMainAttributes();
- String version = attributes.getValue(seamVersionAttributeName);
- return version;
- } catch (IOException e) {
- return null;
- }
- }
-
- public static boolean isJbpm3(String location) {
- return new
Path(location).append("/src/resources/gpd/version.info.xml").toFile().exists();
- }
-
- public static boolean isJbpm4(String location) {
- return new Path(location).append("/jbpm.jar").toFile().exists();
- }
-
- private boolean isValidJbpmInstallation(String location) {
- return isJbpm3(location) || isJbpm4(location);
- }
-}
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 2011-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/JBossRuntimeStartup.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -20,6 +20,7 @@
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
+import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -35,33 +36,13 @@
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.navigator.CommonNavigator;
-import org.jboss.tools.runtime.handlers.DroolsHandler;
-import org.jboss.tools.runtime.handlers.JBossASHandler;
-import org.jboss.tools.runtime.handlers.JbpmHandler;
-import org.jboss.tools.runtime.handlers.SeamHandler;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
import org.osgi.framework.Bundle;
import org.osgi.service.prefs.BackingStoreException;
public class JBossRuntimeStartup implements IStartup, IJBossRuntimePluginConstants {
-
- private static IJBossRuntimePersistanceHandler[] jBossRuntimePersistanceHandler = null;
- public static interface IJBossRuntimePersistanceHandler {
- public void initializeRuntimes(List<ServerDefinition> serverDefinitions);
- public void importRuntimes();
- public void exportRuntimes();
- }
-
- public static IJBossRuntimePersistanceHandler[] getPersistanceHandlers() {
- if (jBossRuntimePersistanceHandler == null) {
- jBossRuntimePersistanceHandler = new IJBossRuntimePersistanceHandler[] {
- new JbpmHandler(),
- new DroolsHandler(),
- new JBossASHandler(),
- new SeamHandler()
- };
- }
- return jBossRuntimePersistanceHandler;
- }
private List<ServerDefinition> serverDefinitions = new
ArrayList<ServerDefinition>();
private IEclipsePreferences preferences;
@@ -75,9 +56,11 @@
}
public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
- IJBossRuntimePersistanceHandler[] handlers = getPersistanceHandlers();
- for( int i = 0; i < handlers.length; i++ ) {
- handlers[i].initializeRuntimes(serverDefinitions);
+ Set<IRuntimeDetector> detectors = RuntimeCoreActivator.getRuntimeDetectors();
+ for( IRuntimeDetector detector:detectors) {
+ if (detector.isEnabled()) {
+ detector.initializeRuntimes(serverDefinitions);
+ }
}
refreshCommonNavigator();
}
@@ -172,9 +155,7 @@
}
});
}
-
-
private void parseServerFile() {
try {
Deleted:
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 2011-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/ServerDefinition.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -1,180 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008-2009 JBoss by Red Hat and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- *
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.runtime;
-
-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
- *
- */
-public class ServerDefinition {
-
- private String name;
- private String version;
- private String type;
- private String description;
- private File location;
- private boolean enabled = true;
-
- public ServerDefinition(String name, String version, String type,
- File location) {
- super();
- this.name = name;
- this.version = version;
- this.type = type;
- this.location = location;
- this.description = null;
- }
-
- /**
- * @param serverBean
- */
- public ServerDefinition(ServerBean serverBean) {
- this.name = serverBean.getName();
- this.version = serverBean.getVersion();
- this.type = serverBean.getType().getId();
- this.location = new File(serverBean.getLocation());
- }
-
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getVersion() {
- return version;
- }
- 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
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((location == null) ? 0 : location.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- result = prime * result + ((version == null) ? 0 : version.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ServerDefinition other = (ServerDefinition) obj;
- if (location == null) {
- if (other.location != null)
- return false;
- } else if (!location.equals(other.location))
- return false;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- if (type == null) {
- if (other.type != null)
- return false;
- } else if (!type.equals(other.type))
- return false;
- if (version == null) {
- if (other.version != null)
- return false;
- } else if (!version.equals(other.version))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "ServerDefinition [name=" + name + ", version=" + version
- + ", type=" + type + ", location=" + location + "]";
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- 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 2011-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/DroolsHandler.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -11,16 +11,18 @@
package org.jboss.tools.runtime.handlers;
import java.io.File;
+import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
import org.drools.eclipse.util.DroolsRuntime;
import org.drools.eclipse.util.DroolsRuntimeManager;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.tools.runtime.IJBossRuntimePluginConstants;
-import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
-import org.jboss.tools.runtime.ServerDefinition;
+import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
-public class DroolsHandler implements
IJBossRuntimePersistanceHandler,IJBossRuntimePluginConstants {
+public class DroolsHandler extends AbstractRuntimeDetector implements
IJBossRuntimePluginConstants {
public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
DroolsRuntime[] existingRuntimes = DroolsRuntimeManager.getDroolsRuntimes();
@@ -32,7 +34,7 @@
}
for (ServerDefinition serverDefinition : serverDefinitions) {
String type = serverDefinition.getType();
- if (!droolsExists(serverDefinition)) {
+ if (serverDefinition.isEnabled() && !droolsExists(serverDefinition)) {
if (SOA_P.equals(type) || DROOLS.equals(type)) {
File droolsRoot = serverDefinition.getLocation(); //$NON-NLS-1$
if (droolsRoot.isDirectory()) {
@@ -72,7 +74,31 @@
return false;
}
- public static String includeDrools(ServerDefinition serverDefinition) {
+ public ServerDefinition getServerDefinition(File root,
+ IProgressMonitor monitor) {
+ if (monitor.isCanceled() || root == null) {
+ return null;
+ }
+ String[] files = root.list(new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+ if (name.startsWith("drools-api") &&
name.endsWith(".jar") ) {
+ return true;
+ }
+ return false;
+ }
+ });
+ if (files != null && files.length > 0) {
+ String version = getImplementationVersion(root,files[0]);
+ if (version != null) {
+ version = version.substring(0,3);
+ return new ServerDefinition(root.getName(), version, DROOLS,
root.getAbsoluteFile());
+ }
+ }
+ return null;
+ }
+
+ public static String included(ServerDefinition serverDefinition) {
StringBuilder builder = new StringBuilder();
File droolsRoot = serverDefinition.getLocation(); //$NON-NLS-1$
if (droolsRoot.isDirectory()) {
@@ -84,14 +110,12 @@
}
return builder.toString();
}
- public void importRuntimes() {
- // TODO Auto-generated method stub
-
- }
- public void exportRuntimes() {
- // TODO Auto-generated method stub
-
+ @Override
+ public boolean exists(ServerDefinition serverDefinition) {
+ if (serverDefinition == null || serverDefinition.getLocation() == null) {
+ return false;
+ }
+ return droolsExists(serverDefinition);
}
-
}
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-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -10,15 +10,12 @@
******************************************************************************/
package org.jboss.tools.runtime.handlers;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.Properties;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -49,23 +46,21 @@
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerUtil;
-import org.eclipse.wst.server.core.internal.IMemento;
import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
-import org.eclipse.wst.server.core.internal.XMLMemento;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
+import org.jboss.ide.eclipse.as.core.server.bean.ServerBean;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
import org.jboss.tools.runtime.Activator;
import org.jboss.tools.runtime.IJBossRuntimePluginConstants;
-import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
import org.jboss.tools.runtime.Messages;
-import org.jboss.tools.runtime.ServerDefinition;
+import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
-public class JBossASHandler implements IJBossRuntimePersistanceHandler,
IJBossRuntimePluginConstants {
-
+public class JBossASHandler extends AbstractRuntimeDetector implements
IJBossRuntimePluginConstants {
+
public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
createInitialJBossServer();
createJBossServerFromDefinitions(serverDefinitions);
@@ -91,22 +86,40 @@
Activator.log(e,Messages.JBossRuntimeStartup_Cannot_create_new_JBoss_Server);
}
}
+
+ private static File getLocation(ServerDefinition serverDefinition) {
+ String type = serverDefinition.getType();
+ if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || EWP.equals(type)) {
+ return new File(serverDefinition.getLocation(), "jboss-as");
+ }
+ if (SOA_P_STD.equals(type)) {
+ return new File(serverDefinition.getLocation(),"jboss-esb");
//$NON-NLS-1$
+ }
+ if(EWP.equals(type)) {
+ return new File(serverDefinition.getLocation(),"jboss-as-web");
//$NON-NLS-1$
+ }
+ if (AS.equals(type)) {
+ return serverDefinition.getLocation();
+ }
+ return null;
+ }
+
public static void createJBossServerFromDefinitions(List<ServerDefinition>
serverDefinitions) {
for (ServerDefinition serverDefinition:serverDefinitions) {
+ if (!serverDefinition.isEnabled()) {
+ continue;
+ }
+ File asLocation = getLocation(serverDefinition);
+ if (asLocation == null || !asLocation.isDirectory()) {
+ continue;
+ }
String type = serverDefinition.getType();
- if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) ||
SOA_P_STD.equals(type) || EWP.equals(type)) {
- File asLocation = new File(serverDefinition.getLocation(), "jboss-as");
- if(SOA_P_STD.equals(type)) {
- asLocation = new File(serverDefinition.getLocation(),"jboss-esb");
//$NON-NLS-1$
- } else if(EWP.equals(type)){
- asLocation = new File(serverDefinition.getLocation(),"jboss-as-web");
//$NON-NLS-1$
- }
- if (asLocation.isDirectory()) {
- String name = serverDefinition.getName();
- String runtimeName = name + " " + RUNTIME; //$NON-NLS-1$
- int index = getJBossASVersion(asLocation);
- createJBossServer(asLocation,index,name, runtimeName);
- }
+ if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type)
+ || SOA_P_STD.equals(type) || EWP.equals(type)) {
+ String name = serverDefinition.getName();
+ String runtimeName = name + " " + RUNTIME; //$NON-NLS-1$
+ int index = getJBossASVersion(asLocation);
+ createJBossServer(asLocation, index, name, runtimeName);
} else if (AS.equals(type)){
String version = serverDefinition.getVersion();
int index = 2;
@@ -344,64 +357,79 @@
}
- public void importRuntimes() {
- String servers =
Activator.getDefault().getPreferenceStore().getString(Activator.SERVERS);
- if (servers != null && servers.trim().length() > 0) {
- loadServerInstalations(servers);
+ public ServerDefinition getServerDefinition(File root,
+ IProgressMonitor monitor) {
+ if (monitor.isCanceled() || root == null) {
+ return null;
}
- }
- /**
- * @param servers
- */
- private void loadServerInstalations(String servers) {
- InputStream in = null;
- try {
- in = new ByteArrayInputStream(servers.getBytes("UTF-8"));
- IMemento memento = XMLMemento.loadMemento(in);
-
- IMemento[] children = memento.getChildren("server");
- int size = children.length;
-
- for (int i = 0; i < size; i++) {
- ServerEx server = new ServerEx(null);
- server.loadFromMemento(children[i], null);
- IServerWorkingCopy wc = server.createWorkingCopy();
- wc.save(false, null);
- }
- } catch (Exception e) {
- Activator.log(e);
+ ServerBeanLoader loader = new ServerBeanLoader();
+ ServerBean serverBean = loader.loadFromLocation(root);
+
+ if (!JBossServerType.UNKNOWN.equals(serverBean.getType())) {
+ ServerDefinition serverDefinition = new ServerDefinition(serverBean.getName(),
+ serverBean.getVersion(), serverBean.getType().getId(), new
File(serverBean.getLocation()));
+ serverDefinition.setDescription(includedRuntimes(serverDefinition));
+ return serverDefinition;
}
+ return null;
}
- private static final String SERVER_DATA_FILE = "servers.xml";
- public void exportRuntimes() {
- String filename =
ServerPlugin.getInstance().getStateLocation().append(SERVER_DATA_FILE).toOSString();
- if ( !(new File(filename).exists()) ) {
- Activator.getDefault().getPreferenceStore().setValue(Activator.SERVERS,
"");
- return;
+ @Override
+ public String includedRuntimes(ServerDefinition serverDefinition) {
+ if (serverDefinition == null || serverDefinition.getType() == null) {
+ return super.includedRuntimes(serverDefinition);
}
- try {
- XMLMemento memento = (XMLMemento) XMLMemento.loadMemento(filename);
- String xmlString = memento.saveToString();
- Activator.getDefault().getPreferenceStore().setValue(Activator.SERVERS, xmlString);
- Activator.getDefault().savePluginPreferences();
- } catch (Exception e) {
- Activator.log (e);
+ StringBuilder builder = new StringBuilder();
+ String type = serverDefinition.getType();
+
+ if (SOA_P.equals(type) || EAP.equals(type) || EPP.equals(type) || EWP.equals(type)) {
+ String includeSeam = SeamHandler.included(serverDefinition);
+ append(builder, includeSeam);
}
+ if (SOA_P.equals(type)) {
+ String includeDrools = DroolsHandler.included(serverDefinition);
+ append(builder, includeDrools);
+ String includeJbpm = JbpmHandler.included(serverDefinition);
+ append(builder, includeJbpm);
+ }
+ return builder.toString();
+
}
- private static class ServerEx extends Server {
- /**
- * @param file
- */
- public ServerEx(IFile file) {
- super(file);
+ 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);
}
-
- @Override
- public void loadFromMemento(IMemento memento, IProgressMonitor monitor) {
- super.loadFromMemento(memento, monitor);
+ }
+
+ @Override
+ public boolean exists(ServerDefinition serverDefinition) {
+ if (serverDefinition == null || serverDefinition.getLocation() == null) {
+ return false;
}
-
+ File location = getLocation(serverDefinition);
+ if (location == null || !location.isDirectory()) {
+ return false;
+ }
+ String path = location.getAbsolutePath();
+ if (path == null) {
+ return false;
+ }
+ IServer[] servers = ServerCore.getServers();
+ for (int i = 0; i < servers.length; i++) {
+ IRuntime runtime = servers[i].getRuntime();
+ if (runtime == null || runtime.getLocation() == null) {
+ continue;
+ }
+ if(path.equals(runtime.getLocation().toOSString())) {
+ return true;
+ }
+ }
+ return false;
}
}
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-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/JbpmHandler.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -10,40 +10,54 @@
************************************************************************************/
package org.jboss.tools.runtime.handlers;
-import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import org.eclipse.wst.server.core.internal.IMemento;
-import org.eclipse.wst.server.core.internal.XMLMemento;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.jboss.tools.jbpm.preferences.JbpmInstallation;
import org.jboss.tools.jbpm.preferences.PreferencesManager;
-import org.jboss.tools.runtime.Activator;
import org.jboss.tools.runtime.IJBossRuntimePluginConstants;
-import org.jboss.tools.runtime.JBossRuntimeLocator;
-import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
-import org.jboss.tools.runtime.ServerDefinition;
+import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
-public class JbpmHandler implements
IJBossRuntimePersistanceHandler,IJBossRuntimePluginConstants {
+public class JbpmHandler extends AbstractRuntimeDetector implements
IJBossRuntimePluginConstants {
+
+ private static final String JBPM3 = "jBPM3";
+
+ private static final String JBPM4 = "jBPM4";
+
+ public static File getJbpmRoot(ServerDefinition serverDefinition) {
+ String type = serverDefinition.getType();
+ if (SOA_P.equals(type)) {
+ return new File(serverDefinition.getLocation(),"jbpm-jpdl"); //$NON-NLS-1$
+ }
+ if (JBPM.equals(type)) {
+ return serverDefinition.getLocation();
+ }
+ return null;
+ }
+
public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
for (ServerDefinition serverDefinition : serverDefinitions) {
- if (!jbpmExists(serverDefinition)) {
+ if (serverDefinition.isEnabled() && !jbpmExists(serverDefinition)) {
+ File jbpmRoot = getJbpmRoot(serverDefinition);
+ if (jbpmRoot == null || !jbpmRoot.isDirectory()) {
+ continue;
+ }
String type = serverDefinition.getType();
if (SOA_P.equals(type)) {
- 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;
+ String version = JBPM3;
+ if (isJbpm4(serverDefinition.getLocation().getAbsolutePath())) {
+ version = JBPM4;
}
PreferencesManager.getInstance().initializeDefaultJbpmInstallation(serverDefinition.getName(),
jbpmRoot.getAbsolutePath(), version);
}
} else if (JBPM.equals(type)) {
- PreferencesManager.getInstance().addJbpmInstallation(serverDefinition.getName(),
serverDefinition.getLocation().getAbsolutePath(), serverDefinition.getVersion());
+ PreferencesManager.getInstance().addJbpmInstallation(serverDefinition.getName(),
jbpmRoot.getAbsolutePath(), serverDefinition.getVersion());
}
}
}
@@ -55,84 +69,69 @@
* @return
*/
public static boolean jbpmExists(ServerDefinition serverDefinition) {
+ File jbpmRoot = getJbpmRoot(serverDefinition);
+ if (jbpmRoot == null || !jbpmRoot.isDirectory()) {
+ return false;
+ }
Map<String, JbpmInstallation> jbpmMap =
PreferencesManager.getInstance().getJbpmInstallationMap();
Collection<JbpmInstallation> jbpmInstalations = jbpmMap.values();
for (JbpmInstallation jbpm:jbpmInstalations) {
String location = jbpm.location;
- if (location != null &&
location.equals(serverDefinition.getLocation().getAbsolutePath())) {
+ if (location != null && location.equals(jbpmRoot.getAbsolutePath())) {
return true;
}
}
return false;
}
-
- /**
- * @param jbpms
- */
- public static void loadJBPMInstalations(String jbpms) {
- InputStream in = null;
- try {
- in = new ByteArrayInputStream(jbpms.getBytes("UTF-8"));
- IMemento memento = XMLMemento.loadMemento(in);
- IMemento[] children = memento.getChildren("installation");
- for (int i = 0; i < children.length; i++) {
- JbpmInstallation installation = new JbpmInstallation();
- installation.name = children[i].getString("name");
- installation.location = children[i].getString("location");
- installation.version = children[i].getString("version");
- PreferencesManager.getInstance().getJbpmInstallationMap()
- .put(installation.name, installation);
- }
- } catch (Exception e) {
- Activator.log(e);
- } finally {
- try {
- if (in != null) {
- in.close();
- }
- } catch (IOException e) {
- }
- }
- }
- public static void exportJbpms() {
- File file =
org.jboss.tools.jbpm.Activator.getDefault().getStateLocation().append("jbpm-installations.xml").toFile();
- if (!file.exists()) {
- Activator.getDefault().getPreferenceStore().setValue(Activator.JBPMS, "");
- return;
+ public ServerDefinition getServerDefinition(File root,
+ IProgressMonitor monitor) {
+ if (monitor.isCanceled() || root == null) {
+ return null;
}
- try {
- XMLMemento memento = (XMLMemento) XMLMemento.loadMemento(file.getAbsolutePath());
- String xmlString = memento.saveToString();
- Activator.getDefault().getPreferenceStore().setValue(Activator.JBPMS, xmlString);
- Activator.getDefault().savePluginPreferences();
- } catch (Exception e) {
- Activator.log (e);
+ boolean isJBPM = isValidJbpmInstallation(root.getAbsolutePath());
+ if (isJBPM) {
+ String version = "unknown";
+ if (isJbpm3(root.getAbsolutePath())) {
+ version = JBPM3;
+ } else if (isJbpm4(root.getAbsolutePath())) {
+ version = JBPM4;
+ }
+ return new ServerDefinition(root.getName(), version, JBPM, root.getAbsoluteFile());
}
+ return null;
}
-
- public static String includeJbpm(ServerDefinition serverDefinition) {
+
+ public static boolean isJbpm3(String location) {
+ return new
Path(location).append("/src/resources/gpd/version.info.xml").toFile().exists();
+ }
+
+ public static boolean isJbpm4(String location) {
+ return new Path(location).append("/jbpm.jar").toFile().exists();
+ }
+
+ private boolean isValidJbpmInstallation(String location) {
+ return isJbpm3(location) || isJbpm4(location);
+ }
+
+ public static String included(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;
+ String version = JBPM3;
+ if (isJbpm4(serverDefinition.getLocation().getAbsolutePath())) {
+ version = 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) {
- JbpmHandler.loadJBPMInstalations(jbpms);
+
+ @Override
+ public boolean exists(ServerDefinition serverDefinition) {
+ if (serverDefinition == null || serverDefinition.getLocation() == null) {
+ return false;
}
+ return jbpmExists(serverDefinition);
}
-
- public void exportRuntimes() {
- JbpmHandler.exportJbpms();
- }
-
}
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-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -11,26 +11,50 @@
package org.jboss.tools.runtime.handlers;
import java.io.File;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.service.datalocation.Location;
import org.jboss.tools.runtime.Activator;
import org.jboss.tools.runtime.IJBossRuntimePluginConstants;
-import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
-import org.jboss.tools.runtime.ServerDefinition;
+import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
import org.jboss.tools.seam.core.SeamUtil;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
-public class SeamHandler implements IJBossRuntimePersistanceHandler,
IJBossRuntimePluginConstants {
+public class SeamHandler extends AbstractRuntimeDetector implements
IJBossRuntimePluginConstants {
+
+ private final static String seamJarName = "jboss-seam.jar";
+ private final static String seamVersionAttributeName = "Seam-Version";
+
+ 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 (SEAM.equals(type)) {
+ return serverDefinition.getLocation();
+ }
+ return null;
+ }
+
public void initializeRuntimes(List<ServerDefinition> serverDefinitions) {
Map<String, SeamRuntime> map = new HashMap<String,SeamRuntime>();
@@ -39,6 +63,9 @@
// 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) {
@@ -145,34 +172,6 @@
return ""; //$NON-NLS-1$
}
- public void importRuntimes() {
- // TODO Auto-generated method stub
-
- }
-
- public void exportRuntimes() {
- // TODO Auto-generated method stub
-
- }
-
- 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;
@@ -203,4 +202,83 @@
return false;
}
+ public ServerDefinition getServerDefinition(File root,
+ IProgressMonitor monitor) {
+ if (monitor.isCanceled() || root == null) {
+ return null;
+ }
+ String seamVersion = getSeamVersionFromManifest(root.getAbsolutePath());
+ if (seamVersion != null) {
+ return new ServerDefinition(root.getName(), seamVersion, SEAM,
root.getAbsoluteFile());
+ }
+ return null;
+ }
+
+ 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);
+ if(!jarFile.isFile()) {
+ return null;
+ }
+ }
+ try {
+ JarFile jar = new JarFile(jarFile);
+ Attributes attributes = jar.getManifest().getMainAttributes();
+ String version = attributes.getValue(seamVersionAttributeName);
+ return version;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ public static String included(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();
+ }
+
+ @Override
+ public boolean exists(ServerDefinition serverDefinition) {
+ if (serverDefinition == null || serverDefinition.getLocation() == null) {
+ return false;
+ }
+ File seamRoot = getSeamRoot(serverDefinition);
+ if (seamRoot == null || !seamRoot.isDirectory()) {
+ return false;
+ }
+ String path = seamRoot.getAbsolutePath();
+ return seamExists(path);
+ }
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/JBossRuntimePreferencesInitializer.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/JBossRuntimePreferencesInitializer.java 2011-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/JBossRuntimePreferencesInitializer.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -1,3 +1,13 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2009 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.runtime.preferences;
import org.eclipse.core.runtime.Preferences;
Deleted:
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 2011-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimeDialog.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -1,154 +0,0 @@
-package org.jboss.tools.runtime.preferences;
-
-import java.io.File;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.jboss.tools.runtime.ServerDefinition;
-
-public class RuntimeDialog extends Dialog {
-
- private List<ServerDefinition> serverDefinitions;
- private String path;
- private CheckboxTableViewer tableViewer;
-
- public RuntimeDialog(Shell parentShell, List<ServerDefinition> serverDefinitions ,
String path) {
- super(parentShell);
- setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
- | SWT.MODELESS | SWT.RESIZE | getDefaultOrientation());
- this.serverDefinitions = serverDefinitions;
- this.path = path;
-
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite area = (Composite) super.createDialogArea(parent);
- Composite contents = new Composite(area, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 400;
- gd.widthHint = 700;
- contents.setLayoutData(gd);
- contents.setLayout(new GridLayout());
- getShell().setText("JBoss Runtimes");
- applyDialogFont(contents);
- initializeDialogUnits(area);
-
- Label label = new Label(contents, SWT.NULL);
- String runtime = (serverDefinitions.size() == 1) ? "runtime" :
"runtimes";
- label.setText("The search found " + serverDefinitions.size() + " "
+ runtime + " while searching " + path + ".");
- tableViewer = CheckboxTableViewer.newCheckList(contents, SWT.V_SCROLL
- | SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
- Table table = tableViewer.getTable();
- gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 100;
- table.setLayoutData(gd);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- 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);
- tc.setText(columnNames[i]);
- tc.setWidth(columnWidths[i]);
- }
-
- tableViewer.setLabelProvider(new RuntimeLabelProvider());
- tableViewer.setContentProvider(new RuntimeContentProvider(serverDefinitions));
- tableViewer.setInput(serverDefinitions);
- for (ServerDefinition definition:serverDefinitions) {
- tableViewer.setChecked(definition, definition.isEnabled());
- }
- tableViewer.addCheckStateListener(new ICheckStateListener() {
-
- public void checkStateChanged(CheckStateChangedEvent event) {
- ServerDefinition definition = (ServerDefinition) event.getElement();
- definition.setEnabled(!definition.isEnabled());
- boolean enableOk = false;
- for (ServerDefinition serverDefinition:serverDefinitions) {
- if (serverDefinition.isEnabled()) {
- enableOk = true;
- }
- }
- getButton(IDialogConstants.OK_ID).setEnabled(enableOk);
- }
- });
- return area;
- }
-
- private class RuntimeLabelProvider extends LabelProvider implements
- ITableLabelProvider {
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof ServerDefinition) {
- ServerDefinition definition = (ServerDefinition) element;
- if (columnIndex == 0) {
- return definition.getName();
- }
- if (columnIndex == 1) {
- return definition.getVersion();
- }
- if (columnIndex == 2) {
- return definition.getType();
- }
- if (columnIndex == 3) {
- File location = definition.getLocation();
- if (location != null) {
- return definition.getLocation().getAbsolutePath();
- }
- }
- if (columnIndex == 4) {
- return definition.getDescription();
- }
- }
- return null;
- }
- }
-
- private class RuntimeContentProvider implements IStructuredContentProvider {
-
- private List<ServerDefinition> serverDefinitions;
-
- public RuntimeContentProvider(List<ServerDefinition> serverDefinitions) {
- this.serverDefinitions = serverDefinitions;
- }
-
- public Object[] getElements(Object inputElement) {
- return serverDefinitions.toArray();
- }
-
- public void dispose() {
-
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- serverDefinitions = (List<ServerDefinition>) newInput;
- }
-
- }
-
-}
Deleted:
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 2011-01-07
20:55:29 UTC (rev 27998)
+++
trunk/runtime/plugins/org.jboss.tools.runtime/src/org/jboss/tools/runtime/preferences/RuntimePreferencePage.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -1,299 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008-2009 JBoss by Red Hat and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- *
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.runtime.preferences;
-
-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.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-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;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-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.jboss.tools.runtime.Activator;
-import org.jboss.tools.runtime.JBossRuntimeLocator;
-import org.jboss.tools.runtime.JBossRuntimeStartup;
-import org.jboss.tools.runtime.JBossRuntimeStartup.IJBossRuntimePersistanceHandler;
-import org.jboss.tools.runtime.ServerDefinition;
-
-/**
- * @author Snjeza
- *
- */
-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$
- private static final String DROOLS_PREFERENCES_ID =
"org.drools.eclipse.preferences.DroolsRuntimesPreferencePage";
- private static final String JBPM_PREFERENCES_ID =
"org.jboss.tools.jbpm.locations";
-
- protected Map<String, Object> map = new HashMap<String, Object>();
-
- private List<ServerDefinition> serverDefinitions;
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse
- * .swt.widgets.Composite)
- */
- @Override
- protected Control createContents(Composite parent) {
- noDefaultAndApplyButton();
- initializeDialogUnits(parent);
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(1, false);
-
- composite.setLayout(layout);
-
- 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);
-
- Label searchLabel = new Label(composite, SWT.NONE);
- searchLabel.setText("JBoss AS, Seam, JBPM and Drools Runtimes will be configured
based on the entered path.");
-
- Group runtimeGroup = new Group(composite, SWT.NONE);
- layout = new GridLayout(1, false);
- runtimeGroup.setLayout(layout);
- runtimeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- runtimeGroup.setText("JBoss Runtimes");
- Button searchButton = createButton(runtimeGroup, "Search for JBoss Runtimes",
"Search...");
- searchButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- search();
- }
-
- });
-
-// Button exportButton = createButton(runtimeGroup, "Export JBoss Runtimes",
"Export...");
-// exportButton.addSelectionListener(new SelectionAdapter() {
-//
-// public void widgetSelected(SelectionEvent e) {
-// exportRuntimes();
-// }
-//
-// });
-//
-// Button importButton = createButton(runtimeGroup, "Import JBoss Runtimes",
"Import...");
-// importButton.addSelectionListener(new SelectionAdapter() {
-//
-// public void widgetSelected(SelectionEvent e) {
-// importRuntimes();
-// }
-//
-// });
-//
- setButtonDimensionHint(searchButton);
-// setButtonDimensionHint(exportButton);
-// setButtonDimensionHint(importButton);
- Dialog.applyDialogFont(composite);
- return composite;
- }
-
- private void exportRuntimes() {
- IJBossRuntimePersistanceHandler[] exportHandlers =
JBossRuntimeStartup.getPersistanceHandlers();
- for( int i = 0; i < exportHandlers.length; i++ ) {
- exportHandlers[i].exportRuntimes();
- }
- PreferencesExportWizard wizard = new PreferencesExportWizard();
- wizard.init(PlatformUI.getWorkbench(), new StructuredSelection());
- WizardDialog dialog = new WizardDialog(getShell(), wizard);
- dialog.create();
- dialog.open();
- }
-
- private void importRuntimes() {
- PreferencesImportWizard wizard = new PreferencesImportWizard();
- wizard.init(PlatformUI.getWorkbench(), new StructuredSelection());
- WizardDialog dialog = new WizardDialog(getShell(), wizard);
- dialog.create();
- int ok = dialog.open();
- if (ok == Window.OK) {
- IJBossRuntimePersistanceHandler[] importHandlers =
JBossRuntimeStartup.getPersistanceHandlers();
- for( int i = 0; i < importHandlers.length; i++ ) {
- importHandlers[i].importRuntimes();
- }
- refreshPreferencePage();
- }
- }
-
- private Button createButton(Composite parent, String labelText, String buttonText) {
- GridLayout layout;
- Composite composite = new Composite(parent,SWT.NONE);
- layout = new GridLayout(2, false);
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(composite, SWT.NONE);
- label.setText(labelText);
- GridData data= new GridData(GridData.FILL, GridData.CENTER, true, false);
- data.widthHint= convertVerticalDLUsToPixels(50);
- label.setLayoutData(data);
-
- Button button = new Button(composite, SWT.PUSH);
- button.setText(buttonText);
- data = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
- //data.widthHint= convertVerticalDLUsToPixels(60);
- button.setLayoutData(data);
- return button;
- }
-
- private void createLink(Composite composite, String text, final String preferencesId) {
- Link link = new Link(composite, SWT.NONE);
- link.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
- link.setText(text);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(getShell(),preferencesId, null, null);
- }
- });
- }
-
- public void init(IWorkbench workbench) {
- }
-
- private void search() {
- IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
- String lastUsedPath= dialogSettings.get(LASTPATH);
- if (lastUsedPath == null) {
- lastUsedPath= ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
- }
- DirectoryDialog dialog = new DirectoryDialog(getShell());
- dialog.setMessage("Search for JBoss Runtimes");
- dialog.setFilterPath(lastUsedPath);
- final String path = dialog.open();
- if (path == null) {
- return;
- }
- dialogSettings.put(LASTPATH, path);
-
- IRunnableWithProgress op = new IRunnableWithProgress() {
-
- public void run(IProgressMonitor monitor) {
- JBossRuntimeLocator locator = new JBossRuntimeLocator();
- serverDefinitions = locator.searchForRuntimes(path, monitor);
-
- }
- };
-
- try {
- serverDefinitions = null;
- new ProgressMonitorDialog(getShell()).run(true, true, op);
- } catch (InvocationTargetException e) {
- Activator.log(e);
- } catch (InterruptedException e) {
- // ignore
- }
-
- if (serverDefinitions == null || serverDefinitions.size() == 0) {
- MessageDialog.openInformation(null, "Search for JBoss Runtimes",
- "The search found 0 runtimes while searching "
- + path + ".");
- } else {
- RuntimeDialog runtimeDialog = new RuntimeDialog(getShell(),
- serverDefinitions, path);
- int ok = runtimeDialog.open();
- if (ok == Window.OK) {
- Iterator<ServerDefinition> iterator = serverDefinitions.iterator();
- while (iterator.hasNext()) {
- ServerDefinition definition = iterator.next();
- if (!definition.isEnabled()) {
- iterator.remove();
- }
- }
- 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.
- * @param button the button
- * @return the width hint
- */
- public static int getButtonWidthHint(Button button) {
- button.setFont(JFaceResources.getDialogFont());
- PixelConverter converter= new PixelConverter(button);
- int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- }
-
- /**
- * Sets width and height hint for the button control.
- * <b>Note:</b> This is a NOP if the button's layout data is not
- * an instance of <code>GridData</code>.
- *
- * @param button the button for which to set the dimension hint
- */
- public static void setButtonDimensionHint(Button button) {
- Assert.isNotNull(button);
- Object gd= button.getLayoutData();
- if (gd instanceof GridData) {
- ((GridData)gd).widthHint= getButtonWidthHint(button);
- ((GridData)gd).horizontalAlignment = GridData.FILL;
- }
- }
-}
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/.classpath
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/.classpath
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/.classpath 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/.project
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/.project
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/.project 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.runtime.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.core/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.core/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/.settings/org.eclipse.jdt.core.prefs 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,8 @@
+#Thu Dec 02 17:06:56 CET 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %BundleName
+Bundle-SymbolicName: org.jboss.tools.runtime.core;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.tools.runtime.core.RuntimeCoreActivator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: %BundleVendor
+Bundle-Localization: plugin
+Export-Package: org.jboss.tools.runtime.core,
+ org.jboss.tools.runtime.core.model
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/about.html
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/about.html
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/about.html 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1" />
+<title>JBoss Runtime Detection</title>
+<style type="text/css" media="screen">
+<!--
+ body {
+ font-family: Sans-serif, Arial, Helvetica;
+ }
+
+-->
+</style>
+</head>
+<body>
+<h1>JBoss Runtime Detection</h1>
+
+<p>
+This plugin is part of the JBoss Tools developed by the <a
href="http://www.jboss.com">JBoss Inc.</a>
+</p>
+
+<p>Information about this plugin is available at <a
href="http://www.jboss.org/tools">JBoss Tools project
page</a></p>
+
+<p>
+This software is distributed under the terms of the Eclipse Public License - v 1.0
+(see <a
href="www.eclipse.org/legal/epl-v10.html">Eclipse Public License
- Version 1.0</a>).
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/about.ini
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/about.ini
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/about.ini 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -0,0 +1,27 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+# test
+# Property "aboutText" contains blurb for "About" dialog
(translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=jboss_about.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (not translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which
the
+# welcome page is to be opened.
+# optional
+
+
+
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/about.mappings
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/about.mappings
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/about.mappings 2011-01-07 20:57:52
UTC (rev 27999)
@@ -0,0 +1,5 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/about.properties
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/about.properties
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/about.properties 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,2 @@
+blurb=JBoss Runtime Detection\n\nVersion\: {featureVersion}\n\n(c) Copyright JBoss by Red
Hat, contributors and others 2004 - 2010. All rights reserved.\nVisit
http\://jboss.org/tools
+
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/build.properties
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/build.properties
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/build.properties 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,12 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ plugin.xml,\
+ schema/,\
+ about.html,\
+ about.ini,\
+ about.mappings,\
+ about.properties,\
+ jboss_about.png
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/jboss_about.png
===================================================================
(Binary files differ)
Property changes on: trunk/runtime/plugins/org.jboss.tools.runtime.core/jboss_about.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.properties
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.properties
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.properties 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,3 @@
+#Properties file for org.jboss.tools.runtime
+BundleVendor = JBoss by Red Hat
+BundleName = JBoss Runtime Detection
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="runtimeDetectors" name="Runtime Detectors"
schema="schema/runtimeDetectors.exsd"/>
+
+</plugin>
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/pom.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/pom.xml
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/pom.xml 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -0,0 +1,14 @@
+<project
+xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>org.jboss.tools.parent.pom</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>org.jboss.tools.runtime.core</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project>
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/runtimeDetectors.exsd
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/runtimeDetectors.exsd
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/runtimeDetectors.exsd 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,147 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.runtime.core"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.jboss.tools.runtime.core"
id="runtimeDetectors" name="Runtime Detectors"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="runtimeDetector"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="runtimeDetector">
+ <complexType>
+ <attribute name="preferenceId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java"
basedOn="org.jboss.tools.runtime.core.model.AbstractRuntimeDetector:"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="enabled" type="boolean">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ <extension
+ point="org.jboss.tools.runtime.core.runtimeDetectors">
+ <runtimeDetector>
+ <name>JBoss AS Runtime</name>
+
<class>org.jboss.tools.runtime.JBossASRuntimeDetector</class>
+
<preferenceId>org.eclipse.wst.server.ui.runtime.preferencePage</preferenceId>
+ </runtimeDetector>
+</extension>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/JBossRuntimeLocator.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/JBossRuntimeLocator.java
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/JBossRuntimeLocator.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.runtime.core;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
+
+/**
+ * @author snjeza
+ *
+ */
+public class JBossRuntimeLocator {
+
+ private static final int DEPTH = 4;
+
+ public JBossRuntimeLocator() {
+ }
+
+ public List<ServerDefinition> searchForRuntimes(String path, IProgressMonitor
monitor) {
+ return searchForRuntimes(new Path(path), monitor);
+ }
+
+ public List<ServerDefinition> searchForRuntimes(IPath path, IProgressMonitor
monitor) {
+ List<ServerDefinition> serverDefinitions = new
ArrayList<ServerDefinition>();
+ Set<IRuntimeDetector> runtimeDetectors =
RuntimeCoreActivator.getRuntimeDetectors();
+ return searchForRuntimes(serverDefinitions, path, DEPTH, runtimeDetectors, monitor);
+ }
+
+ private List<ServerDefinition> searchForRuntimes(List<ServerDefinition>
serverDefinitions, IPath path,
+ int depth, Set<IRuntimeDetector> runtimeDetectors, IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ return serverDefinitions;
+ }
+ File[] children = null;
+ if (path != null) {
+ File root = path.toFile();
+ monitor.setTaskName("Searching " + path.toOSString());
+ ServerDefinition serverDefinition = null;
+ for (IRuntimeDetector detector:runtimeDetectors) {
+ if (monitor.isCanceled()) {
+ return serverDefinitions;
+ }
+ if (!detector.isEnabled()) {
+ continue;
+ }
+ serverDefinition = detector.getServerDefinition(root, monitor);
+ if (serverDefinition != null) {
+ serverDefinitions.add(serverDefinition);
+ break;
+ }
+ }
+ if (serverDefinition == null) {
+ children = root.listFiles();
+ }
+ } else {
+ children = File.listRoots();
+ }
+
+ if (monitor.isCanceled()) {
+ return serverDefinitions;
+ }
+ if (depth == 0) {
+ return serverDefinitions;
+ }
+ if( children != null ) {
+ for( int i = 0; i < children.length; i++ ) {
+ if (monitor.isCanceled()) {
+ return serverDefinitions;
+ }
+ if( children[i].isDirectory()) {
+ if (monitor.isCanceled()) {
+ return serverDefinitions;
+ }
+ searchForRuntimes(serverDefinitions, new Path(children[i].getAbsolutePath()),
+ --depth, runtimeDetectors, monitor);
+ }
+ }
+ }
+ return serverDefinitions;
+ }
+
+}
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,206 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.core;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author snjeza
+ */
+public class RuntimeCoreActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.runtime.core";
//$NON-NLS-1$
+
+ private static final String RUNTIME_DETECTOR_EXTENSION_ID =
"org.jboss.tools.runtime.core.runtimeDetectors";
+
+ private static final String NAME = "name";
+
+ private static final String PREFERENCE_ID = "preferenceId";
+
+ private static final String ID = "id";
+
+ private static final String ENABLED = "enabled";
+
+ private static final String ENABLED_DETECTORS = "enabledDetectors";
+
+ private static final String PRIORITY = "priority";
+
+ private static Set<IRuntimeDetector> runtimeDetectors;
+
+ // The shared instance
+ private static RuntimeCoreActivator plugin;
+
+ private static IEclipsePreferences prefs;
+
+ /**
+ * The constructor
+ */
+ public RuntimeCoreActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static RuntimeCoreActivator getDefault() {
+ return plugin;
+ }
+
+ public static Set<IRuntimeDetector> getDeclaredRuntimeDetectors() {
+ if (runtimeDetectors == null) {
+ runtimeDetectors = new TreeSet<IRuntimeDetector>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry
+ .getExtensionPoint(RUNTIME_DETECTOR_EXTENSION_ID);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IExtension extension = extensions[i];
+ IConfigurationElement[] configurationElements = extension
+ .getConfigurationElements();
+ for (int j = 0; j < configurationElements.length; j++) {
+ IConfigurationElement configurationElement = configurationElements[j];
+ IRuntimeDetector detector;
+ try {
+ detector = (IRuntimeDetector)
configurationElement.createExecutableExtension("class");
+ } catch (CoreException e) {
+ log(e);
+ continue;
+ }
+ String name = configurationElement.getAttribute(NAME);
+ String preferenceId = configurationElement.getAttribute(PREFERENCE_ID);
+ String id = configurationElement.getAttribute(ID);
+ detector.setName(name);
+ detector.setPreferenceId(preferenceId);
+ detector.setId(id);
+ String enabled = configurationElement.getAttribute(ENABLED);
+ if (enabled == null || "true".equals(enabled)) {
+ detector.setEnabled(true);
+ } else {
+ detector.setEnabled(false);
+ }
+ String priorityString = configurationElement
+ .getAttribute(PRIORITY);
+ int priority;
+ try {
+ priority = Integer.parseInt(priorityString);
+ } catch (Exception ex) {
+ priority = Integer.MAX_VALUE;
+ }
+ detector.setPriority(priority);
+ runtimeDetectors.add(detector);
+ }
+ }
+ }
+ return runtimeDetectors;
+ }
+
+ public static void log(Throwable e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, e
+ .getLocalizedMessage(), e);
+ getDefault().getLog().log(status);
+ }
+
+ public static void log(Throwable e, String message) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
+ getDefault().getLog().log(status);
+ }
+
+ public static Set<IRuntimeDetector> getRuntimeDetectors() {
+ Set<IRuntimeDetector> detectors = getDeclaredRuntimeDetectors();
+ String enabledDetectors = getPreferences().get(ENABLED_DETECTORS, null);
+ if (enabledDetectors == null) {
+ saveEnabledDetectors(detectors);
+ } else {
+ StringTokenizer tokenizer = new StringTokenizer(enabledDetectors, ",");
+ List<String> enabled = new ArrayList<String>();
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (token != null && !token.isEmpty()) {
+ enabled.add(token);
+ }
+ }
+ for (IRuntimeDetector detector:detectors) {
+ detector.setEnabled(enabled.contains(detector.getId()));
+ }
+ }
+ return detectors;
+ }
+
+ public static void saveEnabledDetectors(Set<IRuntimeDetector> detectors) {
+ StringBuilder builder = new StringBuilder();
+ for (IRuntimeDetector detector:detectors) {
+ if (detector.isEnabled()) {
+ builder.append(detector.getId());
+ builder.append(",");
+ }
+ }
+ String enabled = builder.toString();
+ int index = enabled.lastIndexOf(",");
+ if (index != -1) {
+ enabled = enabled.substring(0, index);
+ }
+ getPreferences().put(ENABLED_DETECTORS, enabled);
+ try {
+ getPreferences().flush();
+ } catch (BackingStoreException e) {
+ log(e);
+ }
+ }
+
+ private static IEclipsePreferences getPreferences() {
+ if (prefs == null) {
+ prefs = new ConfigurationScope().getNode(PLUGIN_ID);
+ }
+ return prefs;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,127 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.core.model;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+
+/**
+ * @author snjeza
+ *
+ */
+public abstract class AbstractRuntimeDetector implements IRuntimeDetector {
+ private String id;
+ private String name;
+ private String preferenceId;
+ private boolean enabled;
+ private int priority;
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getPreferenceId() {
+ return preferenceId;
+ }
+
+ @Override
+ public void setPreferenceId(String preferenceId) {
+ this.preferenceId = preferenceId;
+ }
+
+ @Override
+ public String includedRuntimes(ServerDefinition serverDefinition) {
+ return "";
+ }
+
+ public String getImplementationVersion(File dir, String file) {
+ File jarFile = new File(dir, file);
+ if(!jarFile.isFile()) {
+ return null;
+ }
+ try {
+ JarFile jar = new JarFile(jarFile);
+ Attributes attributes = jar.getManifest().getMainAttributes();
+ String version = attributes.getValue("Implementation-Version");
+ return version;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ AbstractRuntimeDetector other = (AbstractRuntimeDetector) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+ @Override
+ public int compareTo(IRuntimeDetector o) {
+ if (o == null) {
+ return 1;
+ }
+ int p1 = this.getPriority();
+ int p2 = o.getPriority();
+ return p1 - p2;
+ }
+}
Added:
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
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,50 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.core.model;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * @author snjeza
+ *
+ */
+public interface IRuntimeDetector extends Comparable<IRuntimeDetector> {
+ void initializeRuntimes(List<ServerDefinition> serverDefinitions);
+
+ void setName(String name);
+
+ void setPreferenceId(String preferenceId);
+
+ void setId(String id);
+
+ String getName();
+
+ String getPreferenceId();
+
+ String getId();
+
+ void setEnabled(boolean enabled);
+
+ boolean isEnabled();
+
+ ServerDefinition getServerDefinition(File root, IProgressMonitor monitor);
+
+ String includedRuntimes(ServerDefinition serverDefinition);
+
+ boolean exists(ServerDefinition serverDefinition);
+
+ int getPriority();
+
+ void setPriority(int priority);
+}
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimePath.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimePath.java
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimePath.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,97 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.core.model;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.runtime.core.model.ServerDefinition;
+
+/**
+ * @author snjeza
+ *
+ */
+public class RuntimePath implements Cloneable {
+
+ private String path;
+ private boolean scanOnEveryStartup;
+ private List<ServerDefinition> serverDefinitions;
+ private long timestamp;
+
+ public RuntimePath(String path) {
+ this.path = path;
+ this.scanOnEveryStartup = false;
+ this.serverDefinitions = new ArrayList<ServerDefinition>();
+ this.timestamp = -1;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public boolean isScanOnEveryStartup() {
+ return scanOnEveryStartup;
+ }
+
+ public void setScanOnEveryStartup(boolean scanOnEveryStartup) {
+ this.scanOnEveryStartup = scanOnEveryStartup;
+ }
+
+ public List<ServerDefinition> getServerDefinitions() {
+ return serverDefinitions;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ RuntimePath runtimePath = new RuntimePath(path);
+ runtimePath.setScanOnEveryStartup(scanOnEveryStartup);
+ runtimePath.serverDefinitions = (List<ServerDefinition>)
((ArrayList<ServerDefinition>)serverDefinitions).clone();
+ return runtimePath;
+ }
+
+ public boolean isModified() {
+ if (path == null || path.isEmpty()) {
+ return false;
+ }
+ if (timestamp < 0) {
+ return true;
+ }
+
+ File directory = new File(path);
+ if (! directory.isDirectory()){
+ return false;
+ }
+ try {
+ return directory.lastModified() > timestamp;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "RuntimePath [path=" + path + "]";
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/ServerDefinition.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,144 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.core.model;
+
+import java.io.File;
+
+/**
+ * @author snjeza
+ *
+ */
+public class ServerDefinition {
+
+ private String name;
+ private String version;
+ private String type;
+ private File location;
+ private String description;
+ private boolean enabled = true;
+ private RuntimePath runtimePath;
+
+ public ServerDefinition(String name, String version,
+ String type, File location) {
+ super();
+ this.name = name;
+ this.version = version;
+ this.type = type;
+ this.location = location;
+ this.description = "";
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getVersion() {
+ return version;
+ }
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public File getLocation() {
+ return location;
+ }
+
+ public void setLocation(File location) {
+ this.location = location;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((location == null) ? 0 : location.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ServerDefinition other = (ServerDefinition) obj;
+ if (location == null) {
+ if (other.location != null)
+ return false;
+ } else if (!location.equals(other.location))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ if (version == null) {
+ if (other.version != null)
+ return false;
+ } else if (!version.equals(other.version))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "ServerDefinition [name=" + name + ", version=" + version
+ + ", type=" + type + ", location=" + location + "]";
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public RuntimePath getRuntimePath() {
+ return runtimePath;
+ }
+
+ public void setRuntimePath(RuntimePath runtimePath) {
+ this.runtimePath = runtimePath;
+ }
+
+
+
+}
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/.classpath
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/.classpath
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/.classpath 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/.project
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/.project (rev
0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/.project 2011-01-07 20:57:52 UTC (rev
27999)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.runtime.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/.settings/org.eclipse.jdt.core.prefs 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,8 @@
+#Sat Dec 04 19:39:24 CET 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %BundleName
+Bundle-SymbolicName: org.jboss.tools.runtime.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.tools.runtime.ui.RuntimeUIActivator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.tools.runtime.core,
+ org.eclipse.core.resources
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: %BundleVendor
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/build.properties
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/build.properties
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/build.properties 2011-01-07 20:57:52
UTC (rev 27999)
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ icons/
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/jboss.gif
===================================================================
(Binary files differ)
Property changes on: trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/jboss.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/xpl/complete_tsk.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/xpl/complete_tsk.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/xpl/error_tsk.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/xpl/error_tsk.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/xpl/incomplete_tsk.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/icons/xpl/incomplete_tsk.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.properties
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.properties
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.properties 2011-01-07 20:57:52
UTC (rev 27999)
@@ -0,0 +1,4 @@
+#Properties file for org.jboss.tools.runtime
+BundleVendor = JBoss by Red Hat
+BundleName = JBoss Runtime UI
+JBoss_Runtimes = JBoss Tools Runtime Detection
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.xml
(rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.xml 2011-01-07 20:57:52 UTC
(rev 27999)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.jboss.tools.common.model.ui.MainPreferencePage"
+
class="org.jboss.tools.runtime.ui.preferences.RuntimePreferencePage"
+ id="org.jboss.tools.runtime.preferences.RuntimePreferencePage"
+ name="%JBoss_Runtimes"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup
+
class="org.jboss.tools.runtime.ui.RuntimeScanner"></startup>
+ </extension>
+
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
class="org.jboss.tools.runtime.ui.preferences.JBossRuntimePreferencesInitializer"/>
+ </extension>
+</plugin>
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/pom.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/pom.xml (rev
0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/pom.xml 2011-01-07 20:57:52 UTC (rev
27999)
@@ -0,0 +1,14 @@
+<project
+xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>org.jboss.tools.parent.pom</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>org.jboss.tools.runtime.ui</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project>
Added:
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
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeContentProvider.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,43 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.ui;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
+
+/**
+ * @author snjeza
+ *
+ */
+public class RuntimeContentProvider implements IStructuredContentProvider {
+
+ private List<ServerDefinition> serverDefinitions;
+
+ public RuntimeContentProvider(List<ServerDefinition> serverDefinitions) {
+ this.serverDefinitions = serverDefinitions;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return serverDefinitions.toArray();
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ serverDefinitions = (List<ServerDefinition>) newInput;
+ }
+
+}
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeLabelProvider.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeLabelProvider.java
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeLabelProvider.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,55 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.ui;
+
+import java.io.File;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
+
+/**
+ * @author snjeza
+ *
+ */
+public class RuntimeLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof ServerDefinition) {
+ ServerDefinition definition = (ServerDefinition) element;
+ if (columnIndex == 0) {
+ return definition.getName();
+ }
+ if (columnIndex == 1) {
+ return definition.getVersion();
+ }
+ if (columnIndex == 2) {
+ return definition.getType();
+ }
+ if (columnIndex == 3) {
+ File location = definition.getLocation();
+ if (location != null) {
+ return definition.getLocation().getAbsolutePath();
+ }
+ }
+ if (columnIndex == 4) {
+ return definition.getDescription();
+ }
+ }
+ return null;
+ }
+}
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeScanner.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeScanner.java
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeScanner.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,105 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.ui;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IStartup;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.runtime.core.JBossRuntimeLocator;
+import org.jboss.tools.runtime.core.model.RuntimePath;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
+
+/**
+ * @author snjeza
+ *
+ */
+public class RuntimeScanner implements IStartup {
+
+ @Override
+ public void earlyStartup() {
+ final boolean firstStart = RuntimeUIActivator.getDefault().
+ getPreferenceStore().getBoolean(RuntimeUIActivator.FIRST_START);
+ Job runtimeJob = new Job("Searching runtimes...") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ boolean exists = runtimeExists(firstStart, monitor);
+ if (monitor.isCanceled()) {
+ RuntimeUIActivator.getDefault().refreshRuntimePreferences();
+ return Status.CANCEL_STATUS;
+ }
+ if (exists) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ RuntimeUIActivator.refreshRuntimes(shell,
RuntimeUIActivator.getDefault().getRuntimePaths(), null, false, 7);
+ }
+ });
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ runtimeJob.setUser(false);
+ runtimeJob.setSystem(false);
+ runtimeJob.setPriority(Job.LONG);
+ runtimeJob.schedule(1000);
+
+ RuntimeUIActivator.getDefault().getPreferenceStore().setValue(RuntimeUIActivator.FIRST_START,
false);
+ }
+
+ private boolean runtimeExists(boolean firstStart, IProgressMonitor monitor) {
+ List<RuntimePath> runtimePaths =
RuntimeUIActivator.getDefault().getRuntimePaths();
+ for (RuntimePath runtimePath:runtimePaths) {
+ if (!firstStart && !runtimePath.isScanOnEveryStartup()) {
+ continue;
+ }
+ if (monitor.isCanceled()) {
+ return false;
+ }
+ if (runtimePath.isModified()) {
+ JBossRuntimeLocator locator = new JBossRuntimeLocator();
+ List<ServerDefinition> serverDefinitions =
locator.searchForRuntimes(runtimePath.getPath(), monitor);
+ if (monitor.isCanceled()) {
+ return false;
+ }
+ runtimePath.getServerDefinitions().clear();
+ for (ServerDefinition serverDefinition:serverDefinitions) {
+ serverDefinition.setRuntimePath(runtimePath);
+ }
+ runtimePath.getServerDefinitions().addAll(serverDefinitions);
+ RuntimeUIActivator.setTimestamp(runtimePaths);
+ }
+ monitor.setTaskName("JBoss Runtime Detector: checking " +
runtimePath.getPath());
+ List<ServerDefinition> serverDefinitions = runtimePath.getServerDefinitions();
+ for (ServerDefinition serverDefinition:serverDefinitions) {
+ if (monitor.isCanceled()) {
+ return false;
+ }
+ if (!serverDefinition.isEnabled()) {
+ continue;
+ }
+ monitor.setTaskName("JBoss Runtime Detector: checking " +
serverDefinition.getLocation());
+ if (!RuntimeUIActivator.runtimeCreated(serverDefinition)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,430 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.ui;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+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.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.WorkbenchException;
+import org.eclipse.ui.XMLMemento;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.runtime.core.JBossRuntimeLocator;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.RuntimePath;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
+import org.jboss.tools.runtime.ui.dialogs.SearchRuntimePathDialog;
+import org.jboss.tools.runtime.ui.preferences.RuntimePreferencePage;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author snjeza
+ *
+ */
+public class RuntimeUIActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.runtime.ui";
//$NON-NLS-1$
+
+ // The shared instance
+ private static RuntimeUIActivator plugin;
+
+ private static IEclipsePreferences prefs;
+
+ public static final String LASTPATH = "lastPath";
+
+ public static final String RUNTIME_PATHS = "runtimePaths";
+
+ public static final String PATH = "path";
+
+ public static final String RUNTIME_PATH = "runtimePath";
+
+ public static final String SCAN_ON_EVERY_STAERTUP = "scanOnEveryStartup";
+
+ public static final String TIMESTAMP = "timestamp";
+
+ private static final String SERVER_DEFINITIONS = "serverDefinitions";
+
+ private static final String SERVER_DEFINITION = "serverDefinition";
+
+ private static final String NAME = "name";
+
+ private static final String VERSION = "version";
+
+ private static final String TYPE = "type";
+
+ private static final String LOCATION = "location";
+
+ private static final String DESCRIPTION = "description";
+
+ private static final String ENABLED = "enabled";
+
+ public static final String FIRST_START = "firstStart"; //$NON-NLS-1$
+
+ private List<RuntimePath> runtimePaths = new ArrayList<RuntimePath>();
+
+ private Set<IRuntimeDetector> runtimeDetectors;
+
+ private List<ServerDefinition> serverDefinitions;
+
+ /**
+ * The constructor
+ */
+ public RuntimeUIActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ runtimePaths = null;
+ runtimeDetectors = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ saveRuntimePreferences();
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static RuntimeUIActivator getDefault() {
+ return plugin;
+ }
+
+ public static void log(Throwable e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, e
+ .getLocalizedMessage(), e);
+ RuntimeUIActivator.getDefault().getLog().log(status);
+ }
+
+ public static void log(Throwable e, String message) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
+ RuntimeUIActivator.getDefault().getLog().log(status);
+ }
+
+ public static CheckboxTableViewer createRuntimeViewer(final List<RuntimePath>
runtimePaths2, Composite composite, int heightHint) {
+ GridData gd;
+ CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(composite, SWT.V_SCROLL
+ | SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
+ Table table = viewer.getTable();
+ 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);
+
+ 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);
+ tc.setText(columnNames[i]);
+ tc.setWidth(columnWidths[i]);
+ }
+
+ viewer.setLabelProvider(new RuntimeLabelProvider());
+ List<ServerDefinition> serverDefinitions = new
ArrayList<ServerDefinition>();
+ for (RuntimePath runtimePath:runtimePaths2) {
+ serverDefinitions.addAll(runtimePath.getServerDefinitions());
+ }
+ viewer.setContentProvider(new RuntimeContentProvider(serverDefinitions));
+ viewer.setInput(serverDefinitions);
+ for (ServerDefinition definition:serverDefinitions) {
+ viewer.setChecked(definition, definition.isEnabled());
+ }
+ return viewer;
+ }
+
+ public static void refreshRuntimes(Shell shell, final List<RuntimePath>
runtimePaths, final CheckboxTableViewer viewer, boolean needRefresh, int heightHint) {
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ JBossRuntimeLocator locator = new JBossRuntimeLocator();
+ for (RuntimePath runtimePath : runtimePaths) {
+ List<ServerDefinition> serverDefinitions = locator
+ .searchForRuntimes(runtimePath.getPath(), monitor);
+ runtimePath.getServerDefinitions().clear();
+ for (ServerDefinition serverDefinition : serverDefinitions) {
+ serverDefinition.setRuntimePath(runtimePath);
+ }
+ runtimePath.getServerDefinitions()
+ .addAll(serverDefinitions);
+ }
+ }
+ };
+ try {
+ SearchRuntimePathDialog dialog = new SearchRuntimePathDialog(shell, runtimePaths,
needRefresh, heightHint);
+ dialog.run(true, true, op);
+ if (viewer != null) {
+ dialog.getShell().addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ viewer.setInput(null);
+ List<ServerDefinition> serverDefinitions = new
ArrayList<ServerDefinition>();
+ for (RuntimePath runtimePath : runtimePaths) {
+ serverDefinitions.addAll(runtimePath
+ .getServerDefinitions());
+ viewer.setInput(serverDefinitions);
+ for (ServerDefinition serverDefinition : serverDefinitions) {
+ runtimeExists(serverDefinition);
+ viewer.setChecked(serverDefinition,
+ serverDefinition.isEnabled());
+ }
+ }
+ }
+ });
+ }
+ } catch (InvocationTargetException e1) {
+ RuntimeUIActivator.log(e1);
+ } catch (InterruptedException e1) {
+ // ignore
+ }
+ }
+
+ public static boolean runtimeExists(ServerDefinition serverDefinition) {
+ Set<IRuntimeDetector> detectors = RuntimeCoreActivator.getRuntimeDetectors();
+ for (IRuntimeDetector detector:detectors) {
+ if (detector.exists(serverDefinition)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static void refreshPreferencePage(Shell shell) {
+ if (shell != null && !shell.isDisposed()) {
+ shell.close();
+ }
+ shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(shell,
RuntimePreferencePage.ID, null, null);
+ preferenceDialog.open();
+ }
+
+ public void saveRuntimePreferences() {
+ saveRuntimePaths();
+ if (runtimeDetectors != null) {
+ RuntimeCoreActivator.saveEnabledDetectors(runtimeDetectors);
+ }
+ }
+
+ private void initRuntimePaths() throws WorkbenchException {
+ runtimePaths = new ArrayList<RuntimePath>();
+ String runtimes = getPreferences().get(RUNTIME_PATHS, null);
+ if (runtimes == null || runtimes.isEmpty()) {
+ return;
+ }
+ Reader reader = new StringReader(runtimes);
+ XMLMemento memento = XMLMemento.createReadRoot(reader);
+ IMemento[] nodes = memento.getChildren(RUNTIME_PATH);
+ for (IMemento node:nodes) {
+ String path = node.getString(PATH);
+ boolean scanOnEveryStartup = node.getBoolean(SCAN_ON_EVERY_STAERTUP);
+ String tsString = node.getString(TIMESTAMP);
+ Long timestamp = null;
+ try {
+ timestamp = new Long(tsString);
+ } catch (NumberFormatException e) {
+ // ignore
+ }
+ RuntimePath runtimePath = new RuntimePath(path);
+ runtimePath.setScanOnEveryStartup(scanOnEveryStartup);
+ if (timestamp != null) {
+ runtimePath.setTimestamp(timestamp);
+ }
+ 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.setRuntimePath(runtimePath);
+ runtimePath.getServerDefinitions().add(serverDefinition);
+ }
+ runtimePaths.add(runtimePath);
+
+ }
+ }
+
+ private static IEclipsePreferences getPreferences() {
+ if (prefs == null) {
+ prefs = new ConfigurationScope().getNode(PLUGIN_ID);
+ }
+ return prefs;
+ }
+
+ public void saveRuntimePaths() {
+ if (runtimePaths == null) {
+ return;
+ }
+ XMLMemento memento = XMLMemento.createWriteRoot(RUNTIME_PATHS);
+ Writer writer = null;
+ try {
+ 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());
+ }
+ }
+ writer = new StringWriter();
+ memento.save(writer);
+ writer.flush();
+ String runtimes = writer.toString();
+ getPreferences().put(RUNTIME_PATHS, runtimes);
+ getPreferences().flush();
+ } catch (Exception e) {
+ log(e);
+ } finally {
+ if (writer != null) {
+ try {
+ writer.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ public List<RuntimePath> getRuntimePaths() {
+ if (runtimePaths == null) {
+ try {
+ initRuntimePaths();
+ } catch (WorkbenchException e) {
+ log(e);
+ runtimePaths = new ArrayList<RuntimePath>();
+ }
+ }
+ return runtimePaths;
+ }
+
+ public List<ServerDefinition> getServerDefinitions() {
+ if (serverDefinitions == null) {
+ serverDefinitions = new ArrayList<ServerDefinition>();
+ } else {
+ serverDefinitions.clear();
+ }
+ for (RuntimePath runtimePath:getRuntimePaths()) {
+ serverDefinitions.addAll(runtimePath.getServerDefinitions());
+ }
+ return serverDefinitions;
+ }
+
+ public Set<IRuntimeDetector> getRuntimeDetectors() {
+ if (runtimeDetectors == null) {
+ runtimeDetectors = RuntimeCoreActivator.getRuntimeDetectors();
+ }
+ return runtimeDetectors;
+ }
+
+ public void initDefaultRuntimePreferences() {
+ runtimePaths = new ArrayList<RuntimePath>();
+ runtimeDetectors = RuntimeCoreActivator.getDeclaredRuntimeDetectors();
+ }
+
+ public static void setTimestamp(List<RuntimePath> runtimePaths2) {
+ for (RuntimePath runtimePath : runtimePaths2) {
+ String path = runtimePath.getPath();
+ if (path != null && !path.isEmpty()) {
+ File directory = new File(path);
+ if (directory.isDirectory()) {
+ runtimePath.setTimestamp(directory.lastModified());
+ }
+ }
+ }
+ }
+
+ public void refreshRuntimePreferences() {
+ runtimePaths = null;
+ runtimeDetectors = null;
+ }
+
+ public static boolean runtimeCreated(ServerDefinition serverDefinition) {
+ Set<IRuntimeDetector> detectors = getDefault().getRuntimeDetectors();
+ boolean created = false;
+ for (IRuntimeDetector detector:detectors) {
+ if (!detector.isEnabled()) {
+ continue;
+ }
+ if (detector.exists(serverDefinition)) {
+ created = true;
+ break;
+ }
+ }
+ return (created);
+ }
+
+}
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/AutoResizeTableLayout.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/AutoResizeTableLayout.java
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/AutoResizeTableLayout.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,129 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class AutoResizeTableLayout extends TableLayout implements
+ ControlListener {
+
+ private final Table table;
+ private List<ColumnLayoutData> columns = new
ArrayList<ColumnLayoutData>();
+ private boolean autosizing = false;
+
+ public AutoResizeTableLayout(Table table) {
+ this.table = table;
+ table.addControlListener(this);
+ }
+
+ public void addColumnData(ColumnLayoutData data) {
+ columns.add(data);
+ super.addColumnData(data);
+ }
+
+ public void controlMoved(ControlEvent e) {
+ }
+
+ public void controlResized(ControlEvent e) {
+ if (autosizing) {
+ return;
+ }
+ autosizing = true;
+ try {
+ autoSizeColumns();
+ } finally {
+ autosizing = false;
+ }
+ }
+
+ private void autoSizeColumns() {
+ int width = table.getClientArea().width;
+ if (width <= 1) {
+ return;
+ }
+
+ TableColumn[] tableColumns = table.getColumns();
+ int size =
+ Math.min(columns.size(), tableColumns.length);
+ int[] widths = new int[size];
+ int fixedWidth = 0;
+ int numberOfWeightColumns = 0;
+ int totalWeight = 0;
+
+ // First calc space occupied by fixed columns.
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnPixelData) {
+ int pixels = ((ColumnPixelData)col).width;
+ widths[i] = pixels;
+ fixedWidth += pixels;
+ } else if (col instanceof ColumnWeightData) {
+ ColumnWeightData cw = (ColumnWeightData)col;
+ numberOfWeightColumns++;
+ int weight = cw.weight;
+ totalWeight += weight;
+ } else {
+ throw new IllegalStateException("Unknown column layout data");
+ }
+ }
+
+ // Do we have columns that have a weight?
+ if (numberOfWeightColumns > 0) {
+ // Now, distribute the rest
+ // to the columns with weight.
+ int rest = width - fixedWidth;
+ int totalDistributed = 0;
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnWeightData) {
+ ColumnWeightData cw = (ColumnWeightData)col;
+ int weight = cw.weight;
+ int pixels = totalWeight == 0 ? 0 : weight * rest / totalWeight;
+ totalDistributed += pixels;
+ widths[i] = pixels;
+ }
+ }
+
+ // Distribute any remaining pixels
+ // to columns with weight.
+ int diff = rest - totalDistributed;
+ for (int i = 0; diff > 0; i++) {
+ if (i == size) {
+ i = 0;
+ }
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnWeightData) {
+ ++widths[i];
+ --diff;
+ }
+ }
+ }
+
+ for (int i = 0; i < size; i++) {
+ if (tableColumns[i].getWidth() != widths[i]) {
+ tableColumns[i].setWidth(widths[i]);
+ }
+
+ }
+
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/EditRuntimePathDialog.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,156 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.ui.dialogs;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+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.ICheckStateListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.runtime.core.model.RuntimePath;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
+import org.jboss.tools.runtime.ui.RuntimeUIActivator;
+
+/**
+ * @author snjeza
+ *
+ */
+public class EditRuntimePathDialog extends Dialog {
+
+ private RuntimePath runtimePath;
+ private List<RuntimePath> runtimePaths;
+ private CheckboxTableViewer tableViewer;
+
+ public EditRuntimePathDialog(Shell parentShell, RuntimePath runtimePath) {
+ super(parentShell);
+ setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
+ | SWT.MODELESS | SWT.RESIZE | getDefaultOrientation());
+ this.runtimePath = runtimePath;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ getShell().setText("Edit runtime detection path");
+ Composite area = (Composite) super.createDialogArea(parent);
+ Composite contents = new Composite(area, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 400;
+ gd.widthHint = 700;
+ contents.setLayoutData(gd);
+ contents.setLayout(new GridLayout(1, false));
+ applyDialogFont(contents);
+ initializeDialogUnits(area);
+
+ Composite pathComposite = new Composite(contents, SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ pathComposite.setLayoutData(gd);
+ pathComposite.setLayout(new GridLayout(3, false));
+ Label pathLabel = new Label(pathComposite, SWT.NONE);
+ pathLabel.setText("Path:");
+
+ final Text pathText = new Text(pathComposite, SWT.BORDER);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ pathText.setLayoutData(gd);
+ pathText.setText(runtimePath.getPath());
+
+ Button browseButton = new Button(pathComposite, SWT.NONE);
+ browseButton.setText("Browse...");
+ browseButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IDialogSettings dialogSettings =
RuntimeUIActivator.getDefault().getDialogSettings();
+
+ DirectoryDialog dialog = new DirectoryDialog(getShell());
+ dialog.setMessage("Edit path");
+ dialog.setFilterPath(pathText.getText());
+ final String path = dialog.open();
+ if (path == null) {
+ return;
+ }
+ List<RuntimePath> runtimePaths2 = new ArrayList<RuntimePath>();
+ runtimePaths2.add(runtimePath);
+ RuntimeUIActivator.refreshRuntimes(getShell(), runtimePaths2, null, true, 15);
+ dialogSettings.put(RuntimeUIActivator.LASTPATH, path);
+ pathText.setText(path);
+ }
+
+ });
+
+ Label refreshLabel = new Label(pathComposite, SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.horizontalSpan = 2;
+ refreshLabel.setLayoutData(gd);
+ refreshLabel.setText("Runtimes found at this path. Remove the check mark for any
runtimes you do not want identified.");
+
+ final Button refreshButton = new Button(pathComposite, SWT.NONE);
+ refreshButton.setText("Refresh...");
+ refreshButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ RuntimeUIActivator.refreshRuntimes(getShell(), getRuntimePaths(), tableViewer, false,
15);
+ }
+
+ });
+
+ pathText.addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ runtimePath.setPath(pathText.getText());
+ if (!pathText.getText().isEmpty()) {
+ refreshButton.setEnabled( (new File(pathText.getText()).isDirectory()) );
+ }
+ }
+ });
+ refreshButton.setEnabled( (new File(pathText.getText()).isDirectory()) );
+
+ List<RuntimePath> runtimePaths = getRuntimePaths();
+ tableViewer = RuntimeUIActivator.createRuntimeViewer(runtimePaths, contents, 100);
+ tableViewer.addCheckStateListener(new ICheckStateListener() {
+
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ ServerDefinition definition = (ServerDefinition) event.getElement();
+ definition.setEnabled(!definition.isEnabled());
+ }
+ });
+ return area;
+ }
+
+ private List<RuntimePath> getRuntimePaths() {
+ if (runtimePaths == null) {
+ runtimePaths = new ArrayList<RuntimePath>();
+ runtimePaths.add(runtimePath);
+ }
+ return runtimePaths;
+ }
+
+}
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/RuntimePathEditingSupport.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/RuntimePathEditingSupport.java
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/RuntimePathEditingSupport.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,107 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.ui.dialogs;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.jboss.tools.runtime.core.model.RuntimePath;
+
+/**
+ * @author snjeza
+ *
+ */
+public class RuntimePathEditingSupport extends EditingSupport {
+
+ private CellEditor editor;
+ private int column;
+
+ public RuntimePathEditingSupport(ColumnViewer viewer, int column) {
+ super(viewer);
+ switch (column) {
+ case 0:
+ editor = new TextCellEditor(((TableViewer) viewer).getTable());
+ break;
+ case 1:
+ editor = new CheckboxCellEditor(((TableViewer) viewer).getTable());
+ break;
+ default:
+ editor = new TextCellEditor(((TableViewer) viewer).getTable());
+ }
+
+
+ this.column = column;
+ }
+
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return editor;
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ RuntimePath runtimePath = (RuntimePath) element;
+ String value = null;
+ switch (this.column) {
+ case 0:
+ value = runtimePath.getPath();
+ if (value == null) {
+ value = ""; //$NON-NLS-1$
+ }
+ return value;
+ case 1:
+ boolean scan = runtimePath.isScanOnEveryStartup();
+ return scan;
+ default:
+ break;
+ }
+ return null;
+
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ RuntimePath runtimePath = (RuntimePath) element;
+
+ switch (this.column) {
+ case 0:
+ if (value != null) {
+ runtimePath.setPath(value.toString());
+ } else {
+ runtimePath.setPath(null);
+ }
+ ISelection selection = getViewer().getSelection();
+ getViewer().setSelection(null);
+ getViewer().setSelection(selection);
+ break;
+ case 1:
+ runtimePath.setScanOnEveryStartup((Boolean)value);
+ break;
+
+ default:
+ break;
+ }
+
+ getViewer().update(element, null);
+
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/SearchRuntimePathDialog.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,360 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.ui.dialogs;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.ProgressIndicator;
+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.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.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+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.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.RuntimePath;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
+import org.jboss.tools.runtime.ui.RuntimeUIActivator;
+
+/**
+ * @author snjeza
+ *
+ */
+public class SearchRuntimePathDialog extends ProgressMonitorDialog {
+
+ private List<RuntimePath> runtimePaths = new ArrayList<RuntimePath>();
+ private boolean running = true;
+ private CheckboxTableViewer tableViewer;
+ private boolean canceled;
+ private boolean needRefresh;
+ private Label foundRuntimesLabel;
+ private List<ServerDefinition> serverDefinitions;
+ private Button hideCreatedRuntimes;
+ private int heightHint;
+
+ public SearchRuntimePathDialog(Shell parent, List<RuntimePath> runtimePaths,
boolean needRefresh, int heightHint) {
+ super(parent);
+ setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
+ | SWT.MODELESS | SWT.RESIZE | getDefaultOrientation());
+ this.runtimePaths = runtimePaths;
+ this.needRefresh = needRefresh;
+ this.heightHint = heightHint;
+ }
+
+ /**
+ * Set the message in the message label.
+ *
+ * @param messageString
+ * The string for the new message.
+ * @param force
+ * If force is true then always set the message text.
+ */
+ private void setMessage(String messageString, boolean force) {
+ // must not set null text in a label
+ message = messageString == null ? "" : messageString; //$NON-NLS-1$
+ if (messageLabel == null || messageLabel.isDisposed()) {
+ return;
+ }
+ if (force || messageLabel.isVisible()) {
+ messageLabel.setToolTipText(message);
+ messageLabel.setText(shortenText(message, messageLabel));
+ }
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ getShell().setText("Searching for runtimes...");
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ //gd.heightHint = convertVerticalDLUsToPixels(15);
+ composite.setLayoutData(gd);
+ composite.setLayout(new GridLayout(1, false));
+
+ foundRuntimesLabel = new Label(composite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ foundRuntimesLabel.setLayoutData(gd);
+ foundRuntimesLabel.setFont(parent.getFont());
+ foundRuntimesLabel.setText("");
+
+ setMessage("Searching...", false);
+ createMessageArea(composite);
+ // Only set for backwards compatibility
+ taskLabel = messageLabel;
+
+ tableViewer = RuntimeUIActivator.createRuntimeViewer(runtimePaths, composite,
heightHint);
+ tableViewer.addCheckStateListener(new ICheckStateListener() {
+
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ ServerDefinition definition = (ServerDefinition) event.getElement();
+ definition.setEnabled(!definition.isEnabled());
+ boolean enableOk = false;
+ List<ServerDefinition> serverDefinitions =
getServerDefinitions(hideCreatedRuntimes.getSelection());
+ for (ServerDefinition serverDefinition:serverDefinitions) {
+ if (serverDefinition.isEnabled()) {
+ enableOk = true;
+ }
+ }
+ getButton(IDialogConstants.OK_ID).setEnabled(enableOk);
+ }
+ });
+
+ ColumnViewerEditorActivationStrategy actSupport = new
ColumnViewerEditorActivationStrategy(tableViewer) {
+ protected boolean isEditorActivationEvent(
+ ColumnViewerEditorActivationEvent event) {
+ return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
+ || event.eventType ==
ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
+ || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
+ }
+ };
+
+ TableViewerEditor.create(tableViewer, actSupport,
+ ColumnViewerEditor.TABBING_HORIZONTAL
+ | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
+ | ColumnViewerEditor.TABBING_VERTICAL
+ | ColumnViewerEditor.KEYBOARD_ACTIVATION);
+
+ // label showing current task
+ subTaskLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ gd.heightHint = 0;
+ subTaskLabel.setLayoutData(gd);
+ subTaskLabel.setFont(parent.getFont());
+ // progress indicator
+ progressIndicator = new ProgressIndicator(parent);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ gd.heightHint = 0;
+ progressIndicator.setLayoutData(gd);
+
+ hideCreatedRuntimes = new Button(parent, SWT.CHECK);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = 2;
+ hideCreatedRuntimes.setLayoutData(gd);
+ hideCreatedRuntimes.setText("Hide already created runtimes");
+ hideCreatedRuntimes.setSelection(true);
+
+ hideCreatedRuntimes.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ refresh(null);
+ }
+
+ });
+
+ return parent;
+
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ // OK button
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+ true);
+ // cancel button
+ createCancelButton(parent);
+ }
+
+ @Override
+ protected void cancelPressed() {
+ getProgressMonitor().setCanceled(true);
+ if (running) {
+ canceled = true;
+ } else {
+ setReturnCode(CANCEL);
+ close();
+ }
+ }
+
+ private void refresh(String message) {
+ running = false;
+ tableViewer.setInput(null);
+ List<ServerDefinition> serverDefinitions =
getServerDefinitions(hideCreatedRuntimes.getSelection());
+ tableViewer.setInput(serverDefinitions);
+ for (ServerDefinition definition:serverDefinitions) {
+ tableViewer.setChecked(definition, definition.isEnabled());
+ }
+ TableItem[] tableItems = tableViewer.getTable().getItems();
+ for (TableItem tableItem:tableItems) {
+ Object data = tableItem.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());
+ }
+ }
+ }
+ if (message != null) {
+ setMessage(message, false);
+ }
+ }
+
+ @Override
+ protected void okPressed() {
+ getShell().setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_WAIT));
+ Set<IRuntimeDetector> detectors = RuntimeCoreActivator.getRuntimeDetectors();
+ for( IRuntimeDetector detector:detectors) {
+ if (detector.isEnabled()) {
+ detector.initializeRuntimes(getServerDefinitions(true));
+ }
+ }
+ getShell().setCursor(null);
+ setReturnCode(OK);
+ close();
+ if (needRefresh) {
+ RuntimeUIActivator.refreshPreferencePage(getShell());
+ }
+ }
+
+ @Override
+ protected void finishedRun() {
+ decrementNestingDepth();
+ getShell().setCursor(null);
+ int count = getServerDefinitions(true).size();
+ if (count == 0) {
+ hideCreatedRuntimes.setSelection(false);
+ }
+ if (canceled) {
+ refresh("Searching runtimes is canceled.");
+ } else {
+ refresh("Searching runtimes is finished.");
+ RuntimeUIActivator.setTimestamp(runtimePaths);
+ }
+
+ String foundRuntimes;
+ if (count == 0) {
+ foundRuntimes = "No runtime found.";
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ } else {
+ if (count == 1) {
+ foundRuntimes = count + " new runtime found. Press OK to create the runtimes
with a checkmark.";
+ } else {
+ foundRuntimes = count + " new runtimes found. Press OK to create the runtimes
with a checkmark.";
+ }
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ }
+ foundRuntimesLabel.setText(foundRuntimes);
+ }
+
+ @Override
+ protected Image getImage() {
+ return null;
+ }
+
+ @Override
+ protected Control createMessageArea(Composite composite) {
+ // create message
+ if (message != null) {
+ messageLabel = new Label(composite, getMessageLabelStyle());
+ messageLabel.setText(message);
+ GridDataFactory
+ .fillDefaults()
+ .align(SWT.FILL, SWT.BEGINNING)
+ .grab(true, false)
+ .applyTo(messageLabel);
+ }
+ return composite;
+ }
+
+ private List<ServerDefinition> getServerDefinitions(
+ boolean hideCreatedRuntimes) {
+ if (serverDefinitions == null) {
+ serverDefinitions = new ArrayList<ServerDefinition>();
+ } else {
+ serverDefinitions.clear();
+ }
+ for (RuntimePath runtimePath : runtimePaths) {
+ for (ServerDefinition serverDefinition : runtimePath
+ .getServerDefinitions()) {
+ if (!RuntimeUIActivator.runtimeCreated(serverDefinition)) {
+ List<ServerDefinition> allServerDefinitions =
RuntimeUIActivator.getDefault().getServerDefinitions();
+ String name = serverDefinition.getName();
+ int i = 1;
+ while (serverDefinitionsExists(serverDefinition, allServerDefinitions)) {
+ serverDefinition.setName(name + " " + i++);
+ }
+ }
+ if (!hideCreatedRuntimes) {
+ serverDefinitions.add(serverDefinition);
+ } else if (!RuntimeUIActivator.runtimeCreated(serverDefinition)) {
+ serverDefinitions.add(serverDefinition);
+ }
+ }
+
+ }
+ return serverDefinitions;
+ }
+
+ private boolean serverDefinitionsExists(ServerDefinition serverDefinition,
+ List<ServerDefinition> allServerDefinitions) {
+ String name = serverDefinition.getName();
+ File location = serverDefinition.getLocation();
+ String type = serverDefinition.getType();
+ if (name == null || location == null || type == null) {
+ return false;
+ }
+ String path = location.getAbsolutePath();
+ if (path == null) {
+ return false;
+ }
+ for (ServerDefinition definition:allServerDefinitions) {
+ if (name.equals(definition.getName()) && type.equals(definition.getType())) {
+ File loc = definition.getLocation();
+ if (loc == null) {
+ continue;
+ }
+ String dPath = loc.getAbsolutePath();
+ if (dPath == null) {
+ continue;
+ }
+ if (!path.equals(dPath)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/JBossRuntimePreferencesInitializer.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/JBossRuntimePreferencesInitializer.java
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/JBossRuntimePreferencesInitializer.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,32 @@
+/*************************************************************************************
+ * Copyright (c) 2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.ui.preferences;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.jboss.tools.runtime.ui.RuntimeUIActivator;
+
+/**
+ * @author snjeza
+ *
+ */
+public class JBossRuntimePreferencesInitializer extends
+ AbstractPreferenceInitializer {
+
+ @Override
+ public void initializeDefaultPreferences() {
+ Preferences preferences = RuntimeUIActivator.getDefault().getPluginPreferences();
+ preferences.setDefault(
+ RuntimeUIActivator.FIRST_START,
+ true);
+ }
+
+}
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2011-01-07
20:57:52 UTC (rev 27999)
@@ -0,0 +1,653 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2010 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.ui.preferences;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnViewerEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TableViewerEditor;
+import org.eclipse.jface.viewers.TableViewerFocusCellManager;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.RuntimePath;
+import org.jboss.tools.runtime.core.model.ServerDefinition;
+import org.jboss.tools.runtime.ui.RuntimeContentProvider;
+import org.jboss.tools.runtime.ui.RuntimeLabelProvider;
+import org.jboss.tools.runtime.ui.RuntimeUIActivator;
+import org.jboss.tools.runtime.ui.dialogs.AutoResizeTableLayout;
+import org.jboss.tools.runtime.ui.dialogs.EditRuntimePathDialog;
+import org.jboss.tools.runtime.ui.dialogs.RuntimePathEditingSupport;
+
+/**
+ * @author snjeza
+ *
+ */
+public class RuntimePreferencePage extends PreferencePage implements
+ IWorkbenchPreferencePage {
+
+ public static String ID =
"org.jboss.tools.runtime.preferences.RuntimePreferencePage";
+ private List<RuntimePath> runtimePaths = new ArrayList<RuntimePath>();
+ private Image checkboxOn;
+ private Image checkboxOff;
+ private Image errorIcon;
+ private TableViewer runtimePathViewer;
+ private RuntimePath runtimePath;
+ private Set<IRuntimeDetector> runtimeDetectors;
+ private TableViewer detectorViewer;
+ private Button searchButton;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse
+ * .swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ //noDefaultAndApplyButton();
+ initializeDialogUnits(parent);
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, false);
+
+ composite.setLayout(layout);
+
+ Group pathsGroup = createGroup(composite,1);
+
+ Label pathsDescription = new Label(pathsGroup, SWT.NONE);
+ pathsDescription.setText("Each path on this list will be automatically scanned for
runtimes when\n" +
+ "a new workspace is created or if selected at every Eclipse startup.\n" +
+ "Click Edit to configure rules/filters for the search.");
+
+ Group pathsTableGroup = createGroup(composite,2);
+ runtimePathViewer = createRuntimePathViewer(pathsTableGroup);
+
+ Group detectorGroup = createGroup(composite,1);
+ detectorGroup.setText("Available runtime detectors");
+ detectorViewer = createDetectorViewer(detectorGroup);
+
+// Group runtimeDescriptionGroup = createGroup(composite,1);
+// Label runtimeDescription = new Label(runtimeDescriptionGroup, SWT.NONE);
+// runtimeDescription.setText("Runtimes found at the selected path.\n" +
+// "Remove the check mark for any runtimes you do not want identified.");
+// Group runtimeGroup = createGroup(composite,1);
+// final TableViewer runtimesViewer = createRuntimesViewer(runtimeGroup);
+// runtimePathViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+//
+// @Override
+// public void selectionChanged(SelectionChangedEvent event) {
+// runtimesViewer.setInput(getServerDefinitions());
+// }
+// });
+
+ Dialog.applyDialogFont(composite);
+ return composite;
+ }
+
+ private TableViewer createRuntimesViewer(Composite parent) {
+ CheckboxTableViewer tableViewer = CheckboxTableViewer.newCheckList(parent,
SWT.V_SCROLL
+ | SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
+ Table table = tableViewer.getTable();
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 100;
+ table.setLayoutData(gd);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ String[] columnNames = new String[] { "Name", "Version",
"Type", "Location", "Description"};
+ int[] columnWidths = new int[] { 120, 50, 50, 150, 150};
+
+ for (int i = 0; i < columnNames.length; i++) {
+ TableColumn tc = new TableColumn(table, SWT.LEFT);
+ tc.setText(columnNames[i]);
+ tc.setWidth(columnWidths[i]);
+ }
+
+ tableViewer.setLabelProvider(new RuntimeLabelProvider());
+ final List<ServerDefinition> serverDefinitions = getServerDefinitions();
+ tableViewer.setContentProvider(new RuntimeContentProvider(serverDefinitions));
+ tableViewer.setInput(serverDefinitions);
+ for (ServerDefinition definition:serverDefinitions) {
+ tableViewer.setChecked(definition, definition.isEnabled());
+ }
+ tableViewer.addCheckStateListener(new ICheckStateListener() {
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ ServerDefinition definition = (ServerDefinition) event.getElement();
+ definition.setEnabled(!definition.isEnabled());
+// boolean enableOk = false;
+// for (ServerDefinition serverDefinition:serverDefinitions) {
+// if (serverDefinition.isEnabled()) {
+// enableOk = true;
+// }
+// }
+ }
+ });
+ return tableViewer;
+ }
+
+ private List<ServerDefinition> getServerDefinitions() {
+ List<ServerDefinition> serverDefinitions = new
ArrayList<ServerDefinition>();
+ if (runtimePathViewer == null) {
+ return serverDefinitions;
+ }
+ ISelection selection = runtimePathViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object instanceof RuntimePath) {
+ serverDefinitions = ((RuntimePath)object).getServerDefinitions();
+ }
+ }
+ return serverDefinitions;
+ }
+
+ private Group createGroup(Composite composite, int column) {
+ GridLayout layout;
+ Group group = new Group(composite, SWT.NONE);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ group.setLayoutData(gd);
+ layout = new GridLayout(column, false);
+ group.setLayout(layout);
+ return group;
+ }
+
+ private TableViewer createDetectorViewer(Composite parent) {
+ CheckboxTableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER
+ | SWT.V_SCROLL | SWT.SINGLE);
+ Table table = tableViewer.getTable();
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 150;
+ table.setLayoutData(gd);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ String[] columnNames = new String[] { "Type", "Link"};
+ int[] columnWidths = new int[] { 300, 50};
+
+ for (int i = 0; i < columnNames.length; i++) {
+ TableColumn tc = new TableColumn(table, SWT.LEFT);
+ tc.setText(columnNames[i]);
+ tc.setWidth(columnWidths[i]);
+ }
+
+ tableViewer.setLabelProvider(new RuntimeDetectorLabelProvider());
+ tableViewer.setContentProvider(new RuntimeDetectorContentProvider(runtimeDetectors));
+
+ tableViewer.setInput(runtimeDetectors);
+ for (IRuntimeDetector detector:runtimeDetectors) {
+ tableViewer.setChecked(detector, detector.isEnabled());
+ }
+ tableViewer.addCheckStateListener(new ICheckStateListener() {
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ IRuntimeDetector detector = (IRuntimeDetector) event.getElement();
+ detector.setEnabled(!detector.isEnabled());
+ }
+ });
+ for (int i=0; i<runtimeDetectors.size(); i++) {
+ TableItem item = table.getItem(i);
+ Object data = item.getData();
+ if (data instanceof IRuntimeDetector) {
+ IRuntimeDetector detector = (IRuntimeDetector) data;
+ final String preferenceId = detector.getPreferenceId();
+ if (preferenceId != null && preferenceId.trim().length() > 0) {
+ Link link = new Link(table, SWT.NONE);
+ link.setText(" <a>Link</a>");
+ TableEditor editor = new TableEditor (table);
+ editor.grabHorizontal = editor.grabVertical = true;
+ editor.setEditor (link, item, 1);
+ link.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ PreferencesUtil.createPreferenceDialogOn(getShell(),preferenceId, null, null);
+ }
+ });
+ }
+ }
+ }
+ return tableViewer;
+ }
+
+ private TableViewer createRuntimePathViewer(Composite parent) {
+ final TableViewer viewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION |
SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 150;
+ viewer.getTable().setLayoutData(gd);
+
+ Table table = viewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ table.setFont(parent.getFont());
+
+ viewer.setContentProvider(new RuntimePathContentProvider());
+
+ String[] columnHeaders = {"Path", "Every start"};
+
+ for (int i = 0; i < columnHeaders.length; i++) {
+ TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+ column.setLabelProvider(new RuntimePathLabelProvider(i));
+ column.getColumn().setText(columnHeaders[i]);
+ column.getColumn().setResizable(true);
+ column.getColumn().setMoveable(true);
+ column.setEditingSupport(new RuntimePathEditingSupport(viewer, i));
+
+ }
+
+ ColumnLayoutData[] runtimePathsLayouts= {
+ new ColumnWeightData(150,150),
+ new ColumnWeightData(60,60)
+ };
+
+ TableLayout layout = new AutoResizeTableLayout(table);
+ for (int i = 0; i < runtimePathsLayouts.length; i++) {
+ layout.addColumnData(runtimePathsLayouts[i]);
+ }
+
+ viewer.getTable().setLayout(layout);
+
+ configureViewer(viewer);
+
+
+ viewer.setInput(runtimePaths);
+
+ createRuntimePathsButtons(parent, viewer);
+ return viewer;
+ }
+
+ private void configureViewer(final TableViewer viewer) {
+ TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer,
new FocusCellOwnerDrawHighlighter(viewer));
+
+ ColumnViewerEditorActivationStrategy actSupport = new
ColumnViewerEditorActivationStrategy(viewer) {
+ protected boolean isEditorActivationEvent(
+ ColumnViewerEditorActivationEvent event) {
+ ViewerCell cell = viewer.getColumnViewerEditor().getFocusCell();
+ if (cell != null && cell.getColumnIndex() == 1) {
+ return super.isEditorActivationEvent(event);
+ }
+ return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
+ || event.eventType ==
ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
+ || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED &&
event.keyCode == SWT.CR)
+ || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
+ }
+ };
+
+ TableViewerEditor.create(viewer, focusCellManager, actSupport,
ColumnViewerEditor.TABBING_HORIZONTAL
+ | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
+ | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
+ }
+
+ private void createRuntimePathsButtons(Composite parent, final TableViewer viewer) {
+ Composite buttonComposite = new Composite(parent, SWT.NONE);
+ buttonComposite.setLayout(new GridLayout(1,false));
+ buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
+
+ Button addButton = new Button(buttonComposite, SWT.PUSH);
+ addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ addButton.setText("Add");
+ addButton.addSelectionListener(new SelectionListener(){
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ IDialogSettings dialogSettings =
RuntimeUIActivator.getDefault().getDialogSettings();
+ String lastUsedPath= dialogSettings.get(RuntimeUIActivator.LASTPATH);
+ if (lastUsedPath == null) {
+ lastUsedPath= ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
+ }
+ DirectoryDialog dialog = new DirectoryDialog(getShell());
+ dialog.setMessage("Add a new path");
+ dialog.setFilterPath(lastUsedPath);
+ final String path = dialog.open();
+ if (path == null) {
+ return;
+ }
+ dialogSettings.put(RuntimeUIActivator.LASTPATH, path);
+ RuntimePath runtimePath = new RuntimePath(path);
+ runtimePaths.add(runtimePath);
+ List<RuntimePath> runtimePaths2 = new ArrayList<RuntimePath>();
+ runtimePaths2.add(runtimePath);
+ RuntimeUIActivator.refreshRuntimes(getShell(), runtimePaths2, null, true, 15);
+ configureSearch();
+ runtimePathViewer.setInput(runtimePath.getServerDefinitions());
+ viewer.refresh();
+ }
+
+ });
+
+ final Button editButton = new Button(buttonComposite, SWT.PUSH);
+ editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ editButton.setText("Edit...");
+ editButton.setEnabled(false);
+
+ editButton.addSelectionListener(new SelectionListener(){
+
+ public void widgetSelected(SelectionEvent e) {
+ ISelection sel = viewer.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ if (object instanceof RuntimePath) {
+ runtimePath = (RuntimePath) object;
+ RuntimePath runtimePathClone;
+ try {
+ runtimePathClone = (RuntimePath) runtimePath.clone();
+ } catch (CloneNotSupportedException e1) {
+ RuntimeUIActivator.log(e1);
+ runtimePathClone = runtimePath;
+ }
+ EditRuntimePathDialog dialog = new EditRuntimePathDialog(getShell(),
runtimePathClone);
+ int ok = dialog.open();
+ if (ok == Window.OK) {
+ runtimePaths.remove(runtimePath);
+ runtimePath = runtimePathClone;
+ runtimePaths.add(runtimePath);
+ configureSearch();
+ viewer.refresh();
+ }
+ }
+ }
+ RuntimeUIActivator.refreshPreferencePage(getShell());
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ final Button removeButton = new Button(buttonComposite, SWT.PUSH);
+ removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ removeButton.setText("Remove");
+ removeButton.setEnabled(false);
+
+ removeButton.addSelectionListener(new SelectionListener(){
+
+ public void widgetSelected(SelectionEvent e) {
+ ISelection sel = viewer.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ if (object instanceof RuntimePath) {
+ runtimePaths.remove(object);
+ configureSearch();
+ viewer.refresh();
+ }
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ searchButton = new Button(buttonComposite, SWT.PUSH);
+ searchButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ searchButton.setText("Search...");
+ searchButton.setEnabled(runtimePaths.size() > 0);
+
+ searchButton.addSelectionListener(new SelectionListener(){
+
+ public void widgetSelected(SelectionEvent e) {
+ RuntimeUIActivator.refreshRuntimes(getShell(), runtimePaths, null, true, 15);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection sel = viewer.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ editButton.setEnabled(object instanceof RuntimePath);
+ removeButton.setEnabled(object instanceof RuntimePath);
+ } else {
+ editButton.setEnabled(false);
+ removeButton.setEnabled(false);
+ //searchButton.setEnabled(false);
+ }
+ }
+ });
+ }
+
+ public void init(IWorkbench workbench) {
+ runtimePaths = RuntimeUIActivator.getDefault().getRuntimePaths();
+ runtimeDetectors = RuntimeUIActivator.getDefault().getRuntimeDetectors();
+ checkboxOn = RuntimeUIActivator.imageDescriptorFromPlugin(RuntimeUIActivator.PLUGIN_ID,
"/icons/xpl/complete_tsk.gif").createImage();
+ checkboxOff =
RuntimeUIActivator.imageDescriptorFromPlugin(RuntimeUIActivator.PLUGIN_ID,
"/icons/xpl/incomplete_tsk.gif").createImage();
+ errorIcon = RuntimeUIActivator.imageDescriptorFromPlugin(RuntimeUIActivator.PLUGIN_ID,
"/icons/xpl/error_tsk.gif").createImage();
+ }
+
+ @Override
+ public void dispose() {
+ if (checkboxOff != null) {
+ checkboxOff.dispose();
+ }
+ if (checkboxOn != null) {
+ checkboxOn.dispose();
+ }
+ if (errorIcon != null) {
+ errorIcon.dispose();
+ }
+ super.dispose();
+ }
+
+ /**
+ * Returns a width hint for a button control.
+ * @param button the button
+ * @return the width hint
+ */
+ public static int getButtonWidthHint(Button button) {
+ button.setFont(JFaceResources.getDialogFont());
+ PixelConverter converter= new PixelConverter(button);
+ int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+ }
+
+ /**
+ * Sets width and height hint for the button control.
+ * <b>Note:</b> This is a NOP if the button's layout data is not
+ * an instance of <code>GridData</code>.
+ *
+ * @param button the button for which to set the dimension hint
+ */
+ public static void setButtonDimensionHint(Button button) {
+ Assert.isNotNull(button);
+ Object gd= button.getLayoutData();
+ if (gd instanceof GridData) {
+ ((GridData)gd).widthHint= getButtonWidthHint(button);
+ ((GridData)gd).horizontalAlignment = GridData.FILL;
+ }
+ }
+
+ class RuntimePathContentProvider implements IStructuredContentProvider {
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return runtimePaths.toArray();
+ }
+
+ @Override
+ public void dispose() {
+
+ }
+
+ }
+
+ class RuntimePathLabelProvider extends ColumnLabelProvider {
+
+ private int columnIndex;
+
+ public RuntimePathLabelProvider(int i) {
+ this.columnIndex = i;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof RuntimePath) {
+ RuntimePath runtimePath = (RuntimePath) element;
+ switch (columnIndex) {
+ case 0:
+ return runtimePath.getPath();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element == null) {
+ return null;
+ }
+ RuntimePath runtimePath = (RuntimePath) element;
+ if (columnIndex == 1) {
+ return runtimePath.isScanOnEveryStartup() ? checkboxOn : checkboxOff;
+ }
+ if (columnIndex == 0) {
+ String path = runtimePath.getPath();
+ if (path == null || ! (new File(path).isDirectory())) {
+ return errorIcon;
+ }
+ }
+ return null;
+ }
+ }
+
+ private class RuntimeDetectorContentProvider implements IStructuredContentProvider {
+
+ private Set<IRuntimeDetector> detectors;
+
+ public RuntimeDetectorContentProvider(Set<IRuntimeDetector> detectors) {
+ this.detectors = detectors;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return detectors.toArray();
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ detectors = (Set<IRuntimeDetector>) newInput;
+ }
+ }
+
+ private class RuntimeDetectorLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof IRuntimeDetector) {
+ IRuntimeDetector detector = (IRuntimeDetector) element;
+ if (columnIndex == 0) {
+ return detector.getName();
+ }
+ }
+ return null;
+ }
+ }
+
+ @Override
+ protected void performApply() {
+ RuntimeUIActivator.getDefault().saveRuntimePreferences();
+ }
+
+ @Override
+ protected void performDefaults() {
+ RuntimeUIActivator.getDefault().initDefaultRuntimePreferences();
+ runtimePaths = RuntimeUIActivator.getDefault().getRuntimePaths();
+ runtimeDetectors = RuntimeUIActivator.getDefault().getRuntimeDetectors();
+ runtimePathViewer.setInput(runtimePaths);
+ detectorViewer.setInput(runtimeDetectors);
+ super.performDefaults();
+ }
+
+ @Override
+ public boolean performOk() {
+ RuntimeUIActivator.getDefault().saveRuntimePreferences();
+ return super.performOk();
+ }
+
+ private void configureSearch() {
+ if (searchButton != null) {
+ searchButton.setEnabled(runtimePaths.size() > 0);
+ }
+ }
+
+}
Modified: trunk/runtime/plugins/pom.xml
===================================================================
--- trunk/runtime/plugins/pom.xml 2011-01-07 20:55:29 UTC (rev 27998)
+++ trunk/runtime/plugins/pom.xml 2011-01-07 20:57:52 UTC (rev 27999)
@@ -13,6 +13,8 @@
<packaging>pom</packaging>
<modules>
<module>org.jboss.tools.runtime</module>
+ <module>org.jboss.tools.runtime.core</module>
+ <module>org.jboss.tools.runtime.ui</module>
</modules>
</project>
\ No newline at end of file