[jbosstools-commits] JBoss Tools SVN: r43419 - in trunk: examples/plugins/org.jboss.tools.project.examples and 19 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Sep 5 11:22:35 EDT 2012


Author: rob.stryker at jboss.com
Date: 2012-09-05 11:22:34 -0400 (Wed, 05 Sep 2012)
New Revision: 43419

Added:
   trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd
   trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/Messages.java
   trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/Messages.properties
   trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCorePreferences.java
   trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java
   trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/util/
   trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/util/ECFTransport.java
   trunk/runtime/plugins/org.jboss.tools.runtime.ui/schema/
   trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/
   trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeDialog.java
   trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeViewerDialog.java
   trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimes.java
Removed:
   trunk/examples/plugins/org.jboss.tools.project.examples/OSGI-INF/downloadRuntime.xml
   trunk/examples/plugins/org.jboss.tools.project.examples/schema/downloadruntimes.exsd
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/DownloadRuntimes.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeDialog.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeViewerDialog.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/runtimes/DownloadRuntime.java
   trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/actions/
Modified:
   trunk/as/plugins/org.jboss.tools.runtime.as.detector/plugin.xml
   trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/actions/DownloadRuntimeAction.java
   trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java
   trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF
   trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml
   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/RuntimeExtensionManager.java
   trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF
   trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.xml
   trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.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/preferences/RuntimePreferencePage.java
   trunk/seam/plugins/org.jboss.tools.runtime.seam.detector/plugin.xml
Log:
JBIDE-12448 to trunk

Modified: trunk/as/plugins/org.jboss.tools.runtime.as.detector/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.tools.runtime.as.detector/plugin.xml	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/as/plugins/org.jboss.tools.runtime.as.detector/plugin.xml	2012-09-05 15:22:34 UTC (rev 43419)
@@ -12,4 +12,50 @@
        		priority="100"/>
 	</extension>
 	
+	
+   <extension
+         point="org.jboss.tools.runtime.core.downloadruntimes">
+      <runtime
+            id="org.jboss.tools.runtime.core.as.423" 
+            name="JBoss AS 4.2.3"
+            version="4.2.3"
+            size="100MB"
+            url="http://sourceforge.net/projects/jboss/files/JBoss/JBoss-4.2.3.GA/jboss-4.2.3.GA-jdk6.zip?use_mirror=autoselect"
+            disclaimer="true"/>
+      <runtime
+            id="org.jboss.tools.runtime.core.as.610" 
+            name="JBoss AS 6.1.0"
+            version="6.1.0.Final"
+            size="183MB"
+            url="http://download.jboss.org/jbossas/6.1/jboss-as-distribution-6.1.0.Final.zip?use_mirror=autoselect"
+            disclaimer="true"/>
+      <runtime
+            id="org.jboss.tools.runtime.core.as.701" 
+            name="JBoss AS 7.0.1 Everything (NOT Java EE6 Certified)"
+            version="7.0.1.Final"
+            size="74MB"
+            url="http://download.jboss.org/jbossas/7.0/jboss-as-7.0.1.Final/jboss-as-7.0.1.Final.zip?use_mirror=autoselect"
+            disclaimer="true"/>
+      <runtime
+            id="org.jboss.tools.runtime.core.as.702" 
+            name="JBoss AS 7.0.2 Everything (NOT Java EE6 Certified)"
+            version="7.0.2.Final"
+            size="75MB"
+            url="http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-7.0.2.Final.zip?use_mirror=autoselect"
+            disclaimer="true"/>
+      <runtime
+            id="org.jboss.tools.runtime.core.as.711" 
+            name="JBoss AS 7.1.1 Certified Java EE 6 Full Profile"
+            version="7.1.1.Final"
+            size="127MB"
+            url="http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip?use_mirror=autoselect"
+            disclaimer="true"/>
+      <runtime
+            id="org.jboss.tools.runtime.core.as.710" 
+            name="JBoss AS 7.1.0 Certified Java EE 6 Full Profile"
+            version="7.1.0.Final"
+            size="100MB"
+            url="http://download.jboss.org/jbossas/7.1/jboss-as-7.1.0.Final/jboss-as-7.1.0.Final.zip?use_mirror=autoselect"
+            disclaimer="true"/>
+     </extension>
 </plugin>

Deleted: trunk/examples/plugins/org.jboss.tools.project.examples/OSGI-INF/downloadRuntime.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/OSGI-INF/downloadRuntime.xml	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/OSGI-INF/downloadRuntime.xml	2012-09-05 15:22:34 UTC (rev 43419)
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" 
-   enabled="true" 
-   immediate="true"
-   name="org.jboss.tools.project.examples.DownloadRuntimes">
-   <implementation class="org.jboss.tools.project.examples.DownloadRuntimes"/>
-   <service>
-      <provide interface="org.jboss.tools.runtime.ui.IDownloadRuntimes"/>
-   </service>
-</scr:component>
\ No newline at end of file

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml	2012-09-05 15:22:34 UTC (rev 43419)
@@ -4,7 +4,6 @@
    <extension-point id="projectExamplesXml" name="%ProjectExamples" schema="schema/projectExamplesXml.exsd"/>
    <extension-point id="categories" name="%ProjectExampleCategories" schema="schema/categories.exsd"/>
    <extension-point id="importProjectExamples" name="Import Project Examples" schema="schema/importProjectExample.exsd"/>
-   <extension-point id="downloadruntimes" name="Download Runtimes" schema="schema/downloadruntimes.exsd"/>
    <extension-point id="configurators" name="JBoss Central Configurator" schema="schema/configurators.exsd"/>
    <extension-point id="wizardpages" name="Project Examples Wizard Pages" schema="schema/wizardpages.exsd"/>
    
@@ -88,66 +87,4 @@
         <url>http://download.jboss.org/jbosstools/examples/project-examples-category-3.3.xml</url>
     </extension>
     
-    <extension
-         point="org.jboss.tools.project.examples.downloadruntimes">
-      <runtime
-            id="org.jboss.tools.runtime.core.as.711" 
-            name="JBoss AS 7.1.1 Certified Java EE 6 Full Profile"
-            version="7.1.1.Final"
-            size="127MB"
-            url="http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip?use_mirror=autoselect"
-            disclaimer="true"/>
-      <runtime
-            id="org.jboss.tools.runtime.core.as.710" 
-            name="JBoss AS 7.1.0 Certified Java EE 6 Full Profile"
-            version="7.1.0.Final"
-            size="100MB"
-            url="http://download.jboss.org/jbossas/7.1/jboss-as-7.1.0.Final/jboss-as-7.1.0.Final.zip?use_mirror=autoselect"
-            disclaimer="true"/>
-      <runtime
-            id="org.jboss.tools.runtime.core.as.701" 
-            name="JBoss AS 7.0.1 Everything (NOT Java EE6 Certified)"
-            version="7.0.1.Final"
-            size="74MB"
-            url="http://download.jboss.org/jbossas/7.0/jboss-as-7.0.1.Final/jboss-as-7.0.1.Final.zip?use_mirror=autoselect"
-            disclaimer="true"/>
-      <runtime
-            id="org.jboss.tools.runtime.core.as.702" 
-            name="JBoss AS 7.0.2 Everything (NOT Java EE6 Certified)"
-            version="7.0.2.Final"
-            size="75MB"
-            url="http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-7.0.2.Final.zip?use_mirror=autoselect"
-            disclaimer="true"/>
-      <runtime
-            id="org.jboss.tools.runtime.core.seam.222" 
-            name="JBoss Seam 2.2.2.Final"
-            version="2.2.2.Final"
-            size="113.2MB"
-            url="http://sourceforge.net/projects/jboss/files/JBoss%20Seam/2.2.2.Final/jboss-seam-2.2.2.Final.zip?use_mirror=autoselect"
-            disclaimer="true"/>
-      <runtime
-            id="org.jboss.tools.runtime.core.seam.202" 
-            name="JBoss Seam 2.0.2.SP1"
-            version="2.0.2.SP1"
-            size="92.3MB"
-            url="http://sourceforge.net/projects/jboss/files/JBoss%20Seam/2.0.2.SP1/jboss-seam-2.0.2.SP1.zip?use_mirror=autoselect"
-            disclaimer="true"/>
-      
-      <runtime
-            id="org.jboss.tools.runtime.core.as.610" 
-            name="JBoss AS 6.1.0"
-            version="6.1.0.Final"
-            size="183MB"
-            url="http://download.jboss.org/jbossas/6.1/jboss-as-distribution-6.1.0.Final.zip?use_mirror=autoselect"
-            disclaimer="true"/>
-      <runtime
-            id="org.jboss.tools.runtime.core.as.423" 
-            name="JBoss AS 4.2.3"
-            version="4.2.3"
-            size="100MB"
-            url="http://sourceforge.net/projects/jboss/files/JBoss/JBoss-4.2.3.GA/jboss-4.2.3.GA-jdk6.zip?use_mirror=autoselect"
-            disclaimer="true"/>
-      
-   </extension>
-   
 </plugin>

Deleted: trunk/examples/plugins/org.jboss.tools.project.examples/schema/downloadruntimes.exsd
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/schema/downloadruntimes.exsd	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/schema/downloadruntimes.exsd	2012-09-05 15:22:34 UTC (rev 43419)
@@ -1,134 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.jboss.tools.project.examples" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
-      <appInfo>
-         <meta.schema plugin="org.jboss.tools.project.examples" id="downloadruntimes" name="Download Runtimes"/>
-      </appInfo>
-      <documentation>
-         Downloads a new Runtime
-      </documentation>
-   </annotation>
-
-   <element name="extension">
-      <annotation>
-         <appInfo>
-            <meta.element />
-         </appInfo>
-      </annotation>
-      <complexType>
-         <sequence>
-            <element ref="runtime" minOccurs="1" maxOccurs="unbounded"/>
-         </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="runtime">
-      <complexType>
-         <attribute name="id" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="name" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="version" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="url" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="size" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="disclaimer" type="boolean">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="since"/>
-      </appInfo>
-      <documentation>
-         3.0.0
-      </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>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="copyright"/>
-      </appInfo>
-      <documentation>
-         JBoss by Red Hat
-      </documentation>
-   </annotation>
-
-</schema>

Deleted: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/DownloadRuntimes.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/DownloadRuntimes.java	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/DownloadRuntimes.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -1,15 +0,0 @@
-package org.jboss.tools.project.examples;
-
-import org.eclipse.swt.widgets.Shell;
-import org.jboss.tools.project.examples.dialog.DownloadRuntimeViewerDialog;
-import org.jboss.tools.runtime.ui.IDownloadRuntimes;
-
-public class DownloadRuntimes implements IDownloadRuntimes {
-
-	@Override
-	public void execute(Shell shell) {
-		DownloadRuntimeViewerDialog dialog = new DownloadRuntimeViewerDialog(shell);
-		dialog.open();
-	}
-
-}

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -34,9 +34,6 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
 import org.apache.commons.lang.StringEscapeUtils;
 import org.eclipse.core.filesystem.EFS;
 import org.eclipse.core.filesystem.IFileStore;
@@ -55,7 +52,6 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.OperationCanceledException;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
@@ -115,7 +111,6 @@
 import org.jboss.tools.project.examples.configurators.DefaultJBossCentralConfigurator;
 import org.jboss.tools.project.examples.configurators.IJBossCentralConfigurator;
 import org.jboss.tools.project.examples.dialog.MarkerDialog;
-import org.jboss.tools.project.examples.filetransfer.ECFExamplesTransport;
 import org.jboss.tools.project.examples.fixes.PluginFix;
 import org.jboss.tools.project.examples.fixes.ProjectExamplesFix;
 import org.jboss.tools.project.examples.fixes.SeamRuntimeFix;
@@ -124,7 +119,6 @@
 import org.jboss.tools.project.examples.model.ProjectExample;
 import org.jboss.tools.project.examples.model.ProjectExampleUtil;
 import org.jboss.tools.project.examples.model.ProjectFix;
-import org.jboss.tools.project.examples.runtimes.DownloadRuntime;
 import org.jboss.tools.project.examples.wizard.ContributedPage;
 import org.jboss.tools.project.examples.wizard.ImportDefaultProjectExample;
 import org.jboss.tools.project.examples.wizard.NewProjectExamplesJob;
@@ -132,10 +126,6 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Version;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 /**
  * The activator class controls the plug-in life cycle
@@ -185,13 +175,8 @@
 	public static final boolean SHOW_QUICK_FIX_VALUE = true;
 	
 	private static final String IMPORT_PROJECT_EXAMPLES_EXTENSION_ID = "org.jboss.tools.project.examples.importProjectExamples"; //$NON-NLS-1$
-	private static final String NAME = "name"; //$NON-NLS-1$
 	private static final String TYPE = "type"; //$NON-NLS-1$
-	
-	public static final String DOWNLOAD_RUNTIMES_EXTENSION_ID = "org.jboss.tools.project.examples.downloadruntimes"; //$NON-NLS-1$
-
-	private static final String ID = "id"; //$NON-NLS-1$
-	
+	public static final String NAME = "name"; //$NON-NLS-1$
 	public static final String CLASS = "class"; //$NON-NLS-1$
 	
 	private static final String PRIORITY = "priority"; //$NON-NLS-1$
@@ -239,14 +224,7 @@
 	private ImportDefaultProjectExample defaultImportProjectExample;
 
 	private static final String VERSION = "version"; //$NON-NLS-1$
-	private static final String URL = "url"; //$NON-NLS-1$
-
-	private static final String DISCLAIMER = "disclaimer"; //$NON-NLS-1$
-
-	private static final String DOWNLOAD_RUNTIMES_FILE = "download_runtime.xml"; //$NON-NLS-1$
 	
-	private Map<String, DownloadRuntime> downloadRuntimes;
-	
 	private Map<String, List<ContributedPage>> contributedPages;
 	
 	/**
@@ -1174,114 +1152,6 @@
 		return contributedPages;
 	}
 	
-	public Map<String, DownloadRuntime> getDownloadRuntimes() {
-		if (downloadRuntimes == null) {
-			downloadRuntimes = new HashMap<String, DownloadRuntime>();
-			IExtensionRegistry registry = Platform.getExtensionRegistry();
-			IExtensionPoint extensionPoint = registry
-					.getExtensionPoint(DOWNLOAD_RUNTIMES_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];
-					String name = configurationElement.getAttribute(NAME);
-					String id = configurationElement.getAttribute(ID);
-					String version = configurationElement.getAttribute(VERSION);
-					String url = configurationElement.getAttribute(URL);
-					String disclaimer = configurationElement.getAttribute(DISCLAIMER);
-					DownloadRuntime downloadRuntime = new DownloadRuntime(id, name, version, url);
-					if (Boolean.FALSE.toString().equals(disclaimer)) {
-						downloadRuntime.setDisclaimer(false);
-					}
-					downloadRuntimes.put(id, downloadRuntime);
-				}
-			}
-			addExternalRuntimes();
-		}
-		return downloadRuntimes;
-	}
-	
-	private void addExternalRuntimes() {
-		if (downloadRuntimes == null) {
-			return;
-		}
-		String urlString = getConfigurator().getDownloadRuntimesURL();
-		File cacheFile = null;
-		try {
-			long cacheModified = 0;
-			IPath location = ProjectExamplesActivator.getDefault()
-					.getStateLocation();
-			cacheFile = new File(location.toFile(), DOWNLOAD_RUNTIMES_FILE);
-			if (cacheFile.isFile()) {
-				cacheModified = cacheFile.lastModified();
-			}
-			URL url = new URL(urlString);
-			long urlModified;
-			try {
-				urlModified = ECFExamplesTransport.getInstance()
-						.getLastModified(url);
-			} catch (Exception e) {
-				log(e);
-				urlModified = -1;
-			}
-			if (cacheModified == 0 || urlModified != cacheModified) {
-				File tempFile = File
-						.createTempFile("download_runtimes", ".xml");  //$NON-NLS-1$//$NON-NLS-2$
-				tempFile.deleteOnExit();
-				OutputStream destination = new FileOutputStream(tempFile);
-				IStatus status = ECFExamplesTransport.getInstance().download(
-						DOWNLOAD_RUNTIMES_FILE, urlString, destination,
-						new NullProgressMonitor());
-				if (status.isOK() && url != null) {
-					cacheModified = ECFExamplesTransport.getInstance()
-							.getLastModified(url);
-					ProjectExamplesActivator.copyFile(tempFile, cacheFile);
-					tempFile.delete();
-					cacheFile.setLastModified(cacheModified);
-				} else {
-					getLog().log(status);
-				}
-			}
-		} catch (Exception e) {
-			log(e);
-		}
-		if (cacheFile != null && cacheFile.isFile()) {
-			try {
-				DocumentBuilderFactory dbf = DocumentBuilderFactory
-						.newInstance();
-				DocumentBuilder db = dbf.newDocumentBuilder();
-				Document doc = db.parse(cacheFile);
-				NodeList runtimes = doc.getElementsByTagName("runtime"); //$NON-NLS-1$
-				int len = runtimes.getLength();
-				for (int i = 0; i < len; i++) {
-					Node node = runtimes.item(i);
-					if (node.getNodeType() == Node.ELEMENT_NODE) {
-						Element element = (Element) node;
-						String id = element.getAttribute("id"); //$NON-NLS-1$
-						String name = element.getAttribute("name"); //$NON-NLS-1$
-						String version = element.getAttribute("version"); //$NON-NLS-1$
-						String url = element.getAttribute("url"); //$NON-NLS-1$
-						String disclaimer = element.getAttribute("disclaimer"); //$NON-NLS-1$
-						if (id == null || name == null || version == null || url == null) {
-							ProjectExamplesActivator.log("Invalid runtime: id=" + id + ",name=" + 
-									name + ",version=" + version + ",url=" + url);
-						} else {
-							DownloadRuntime runtime = new DownloadRuntime(id, name, version, url);
-							runtime.setDisclaimer("true".equals(disclaimer)); //$NON-NLS-1$
-							downloadRuntimes.put(id, runtime);
-						}
-					}
-				}
-			} catch (Exception e) {
-				ProjectExamplesActivator.log(e);
-			} 
-		}
-	}
-
-	
 	public IJBossCentralConfigurator getConfigurator() {
 		if (configurator == null) {
 			IExtensionRegistry registry = Platform.getExtensionRegistry();

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/actions/DownloadRuntimeAction.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/actions/DownloadRuntimeAction.java	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/actions/DownloadRuntimeAction.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -10,61 +10,12 @@
  ************************************************************************************/
 package org.jboss.tools.project.examples.actions;
 
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.project.examples.ProjectExamplesActivator;
-import org.jboss.tools.project.examples.dialog.DownloadRuntimeDialog;
-import org.jboss.tools.project.examples.runtimes.DownloadRuntime;
 
 /** 
  * 
  * @author snjeza
  *
  */
-public class DownloadRuntimeAction extends Action {
-
-	private String runtimeId;
-	
-	public DownloadRuntimeAction(String runtimeId) {
-		super();
-		setRuntimeId(runtimeId);
-	}
-
-	private void setRuntimeId(String runtimeId) {
-		Assert.isNotNull(runtimeId);
-		this.runtimeId = runtimeId;
-	}
-
-	public DownloadRuntimeAction(String text, ImageDescriptor image, String runtimeId) {
-		super(text, image);
-		setRuntimeId(runtimeId);
-	}
-
-	public DownloadRuntimeAction(String text, int style, String runtimeId) {
-		super(text, style);
-		setRuntimeId(runtimeId);
-	}
-
-	public DownloadRuntimeAction(String text, String runtimeId) {
-		super(text);
-		setRuntimeId(runtimeId);
-	}
-
-	@Override
-	public void run() {
-		Assert.isNotNull(runtimeId);
-		// FIXME
-		DownloadRuntime runtime = ProjectExamplesActivator.getDefault().getDownloadRuntimes().get(runtimeId);
-		DownloadRuntimeDialog dialog = new DownloadRuntimeDialog(getShell(), runtime);
-		dialog.open();
-	}
-
-	private Shell getShell() {
-		return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-		
-	}
-
+public class DownloadRuntimeAction {
+	// Deprecated / unused
 }

Deleted: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeDialog.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeDialog.java	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeDialog.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -1,600 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc. 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.project.examples.dialog;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.eclipse.core.runtime.CoreException;
-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.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.fieldassist.ControlDecoration;
-import org.eclipse.jface.fieldassist.FieldDecoration;
-import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-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.Display;
-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.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
-import org.eclipse.ui.progress.IProgressService;
-import org.jboss.tools.project.examples.ProjectExamplesActivator;
-import org.jboss.tools.project.examples.filetransfer.ECFExamplesTransport;
-import org.jboss.tools.project.examples.runtimes.DownloadRuntime;
-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.RuntimeDefinition;
-import org.jboss.tools.runtime.core.model.RuntimePath;
-import org.jboss.tools.runtime.ui.RuntimeUIActivator;
-import org.jboss.tools.runtime.ui.preferences.RuntimePreferencePage;
-
-/**
- * @author snjeza
- * 
- */
-public class DownloadRuntimeDialog extends Dialog {
-
-	private static final String SEPARATOR = "/"; //$NON-NLS-1$
-	private static final String FOLDER_IS_REQUIRED = "This folder is required";
-	private static final String FOLDER_IS_NOT_WRITABLE = "This folder does not exist or is not writable";
-	private static final String DELETE_ON_EXIT = "deleteOnExit"; //$NON-NLS-1$
-	private static final String JAVA_IO_TMPDIR = "java.io.tmpdir"; //$NON-NLS-1$
-	private static final String USER_HOME = "user.home"; //$NON-NLS-1$
-	private static final String DEFAULT_DIALOG_PATH = "defaultDialogPath"; //$NON-NLS-1$
-	private static final String DEFAULT_DESTINATION_PATH = "defaultDestinationPath"; //$NON-NLS-1$
-	private IDialogSettings dialogSettings;
-	private Button deleteOnExit;
-	private Text destinationPathText;
-	private Text pathText;
-	private DownloadRuntime downloadRuntime;
-	private String delete;
-	private ControlDecoration decPathError;
-	private ControlDecoration decPathReq;
-	private ControlDecoration destinationPathError;
-	private ControlDecoration destinationPathReq;
-	
-	public DownloadRuntimeDialog(Shell parentShell, DownloadRuntime downloadRuntime) {
-		super(parentShell);
-		setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
-				| SWT.RESIZE | getDefaultOrientation());
-		dialogSettings = ProjectExamplesActivator.getDefault().getDialogSettings();
-		this.downloadRuntime = downloadRuntime;
-	}
-
-	@Override
-	protected Control createDialogArea(Composite parent) {
-		getShell().setText("Download Runtime '" + downloadRuntime.getName() + "'");
-		Composite area = (Composite) super.createDialogArea(parent);
-		Composite contents = new Composite(area, SWT.NONE);
-		GridData gd = new GridData(GridData.FILL_BOTH);
-		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));
-		
-		if (downloadRuntime.isDisclaimer()) {
-			Group disclaimerComposite = new Group(pathComposite, SWT.NONE);
-			gd = new GridData(SWT.FILL, SWT.FILL, true, false);
-			gd.horizontalSpan = 3;
-			disclaimerComposite.setLayoutData(gd);
-			disclaimerComposite.setLayout(new GridLayout(1, false));
-			disclaimerComposite.setText("Warning");
-			new Label(disclaimerComposite, SWT.NONE).setText("This is a community project and, as such is not supported with an SLA.");
-			Link link = new Link(disclaimerComposite, SWT.NONE);
-			link.setText("If you're looking for fully supported, certified, enterprise middleware try JBoss Enterprise Middleware products. <a>Show Details</a>");
-
-			link.addSelectionListener( new SelectionAdapter( ) {
-
-				public void widgetSelected( SelectionEvent e )
-				{
-					String text = e.text;
-					if ("Show Details".equals(text)) {
-						IWorkbenchBrowserSupport support = PlatformUI.getWorkbench()
-								.getBrowserSupport();
-						try {
-							URL url = new URL("http://www.redhat.com/jboss/"); //$NON-NLS-1$
-							support.getExternalBrowser().openURL(url);
-						} catch (Exception e1) {
-							ProjectExamplesActivator.log(e1);
-						}
-					}
-					
-				}
-			} );
-		}
-		Label urlLabel = new Label(pathComposite, SWT.NONE);
-		urlLabel.setText("URL:");
-		Text urlText = new Text(pathComposite, SWT.READ_ONLY|SWT.BORDER);
-		gd = new GridData(SWT.FILL, SWT.FILL, true, false);
-		gd.horizontalSpan=2;
-		urlText.setLayoutData(gd);
-		urlText.setText(downloadRuntime.getUrl());
-		Label pathLabel = new Label(pathComposite, SWT.NONE);
-		pathLabel.setText("Install folder:");
-		
-		pathText = new Text(pathComposite, SWT.BORDER);
-		gd = new GridData(SWT.FILL, SWT.FILL, true, false);
-		pathText.setLayoutData(gd);
-		final String defaultPath = getDefaultPath();
-		pathText.setText(defaultPath);
-		decPathError = addDecoration(pathText, FieldDecorationRegistry.DEC_ERROR, FOLDER_IS_NOT_WRITABLE);
-		decPathReq = addDecoration(pathText, FieldDecorationRegistry.DEC_REQUIRED, FOLDER_IS_REQUIRED);
-		pathText.addModifyListener(new ModifyListener() {
-			
-			@Override
-			public void modifyText(ModifyEvent e) {
-				validate();
-			}
-		});
-		
-		Button browseButton = new Button(pathComposite, SWT.NONE);
-		browseButton.setText("Browse...");
-		browseButton.addSelectionListener(new SelectionAdapter() {
-
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				DirectoryDialog dialog = new DirectoryDialog(getShell());
-				dialog.setMessage("Select install folder");
-				dialog.setFilterPath(pathText.getText());
-				final String path = dialog.open();
-				if (path == null) {
-					return;
-				}
-				pathText.setText(path);
-			}
-		
-		});
-		
-		Label destinationLabel = new Label(pathComposite, SWT.NONE);
-		destinationLabel.setText("Download folder:");
-		
-		destinationPathText = new Text(pathComposite, SWT.BORDER);
-		gd = new GridData(SWT.FILL, SWT.FILL, true, false);
-		destinationPathText.setLayoutData(gd);
-		String destinationPath = dialogSettings.get(DEFAULT_DESTINATION_PATH);
-		destinationPathError = addDecoration(destinationPathText, FieldDecorationRegistry.DEC_ERROR, FOLDER_IS_NOT_WRITABLE);
-		destinationPathReq = addDecoration(destinationPathText, FieldDecorationRegistry.DEC_REQUIRED, FOLDER_IS_REQUIRED);
-		
-		if (destinationPath == null || destinationPath.isEmpty()) {
-			destinationPath=System.getProperty(JAVA_IO_TMPDIR);
-		}
-		destinationPathText.setText(destinationPath);
-		Button browseDestinationButton = new Button(pathComposite, SWT.NONE);
-		browseDestinationButton.setText("Browse...");
-		browseDestinationButton.addSelectionListener(new SelectionAdapter() {
-
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				DirectoryDialog dialog = new DirectoryDialog(getShell());
-				dialog.setMessage("Select download folder");
-				dialog.setFilterPath(destinationPathText.getText());
-				final String path = dialog.open();
-				if (path == null) {
-					return;
-				}
-				destinationPathText.setText(path);
-			}
-		
-		});
-		
-		destinationPathText.addModifyListener(new ModifyListener() {
-			
-			@Override
-			public void modifyText(ModifyEvent e) {
-				validate();
-			}
-		});
-		
-		deleteOnExit = new Button(pathComposite, SWT.CHECK);
-		gd = new GridData(SWT.FILL, SWT.FILL, true, false);
-		gd.horizontalSpan=3;
-		deleteOnExit.setLayoutData(gd);
-		deleteOnExit.setText("Delete archive after installing");
-		
-		delete = dialogSettings.get(DELETE_ON_EXIT);
-		if (delete == null) {
-			delete = "true";
-		}
-		deleteOnExit.setSelection(new Boolean(delete));
-		deleteOnExit.addSelectionListener(new SelectionAdapter() {
-			
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				delete = new Boolean(deleteOnExit.getSelection()).toString();
-			}
-			
-		});
-		
-		return area;
-	}
-
-	private String getDefaultPath() {
-		String defaultPath = dialogSettings.get(DEFAULT_DIALOG_PATH);
-		if (defaultPath == null || defaultPath.isEmpty()) {
-			defaultPath=System.getProperty(USER_HOME);
-		}
-		return defaultPath;
-	}
-
-	private void showDecorations() {
-		String path = pathText.getText();
-		String destination = destinationPathText.getText();
-		decPathError.hide();
-		decPathReq.hide();
-		destinationPathError.hide();
-		destinationPathReq.hide();
-		if (path.isEmpty()) {
-			decPathReq.show();
-		}
-		if (destination.isEmpty()) {
-			destinationPathReq.show();
-		}
-		boolean pathExists = checkPath(path, decPathError);
-		boolean destExists = checkPath(destination, destinationPathError);
-		getButton(IDialogConstants.OK_ID).setEnabled(pathExists
-			&& destExists
-			&& !path.isEmpty() && !destination.isEmpty());
-		decPathError.setShowHover(true);
-	}
-
-	private boolean checkPath(String path, ControlDecoration dec) {
-		if (path.isEmpty()) {
-			return true;
-		}
-		try {
-			File file = File.createTempFile("temp", "txt", new File(path));
-			file.deleteOnExit();
-			file.delete();
-		} catch (IOException e) {
-			dec.show();
-			return false;
-		}
-		return true;
-	}
-
-	protected ControlDecoration addDecoration(Control control, String id, String description) {
-		final ControlDecoration decPath = new ControlDecoration(control, SWT.TOP
-				| SWT.LEFT);
-		FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
-		FieldDecoration fd = registry.getFieldDecoration(id);
-		decPath.setImage(fd.getImage());
-		fd.setDescription(description);
-	
-		decPath.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(
-				id).getImage());
-
-		decPath.setShowOnlyOnFocus(false);
-		decPath.setShowHover(true);
-		decPath.setDescriptionText(description);
-		return decPath;
-	}
-
-	protected void validate() {
-		getButton(IDialogConstants.OK_ID).setEnabled(true);
-		if (pathText.getText().isEmpty()) {
-			getButton(IDialogConstants.OK_ID).setEnabled(false);
-		}
-		if (destinationPathText.getText().isEmpty()) {
-			getButton(IDialogConstants.OK_ID).setEnabled(false);
-		}
-		showDecorations();
-	}
-
-	@Override
-	protected void okPressed() {
-		dialogSettings.put(DEFAULT_DESTINATION_PATH,
-				destinationPathText.getText());
-		dialogSettings.put(DEFAULT_DIALOG_PATH, pathText.getText());
-		dialogSettings.put(DELETE_ON_EXIT, delete);
-		String selectedDirectory = pathText.getText();
-		String destinationDirectory = destinationPathText.getText();
-		boolean del = deleteOnExit.getSelection();
-		super.okPressed();
-		downloadRuntime(selectedDirectory, destinationDirectory, del);
-	}
-
-	private void downloadRuntime(final String selectedDirectory,
-			final String destinationDirectory, final boolean deleteOnExit) {		
-		Job downloadJob = new Job("Download '" + downloadRuntime.getName()) {
-
-			@Override
-			public IStatus run(IProgressMonitor monitor) {
-				monitor.beginTask("Download '" + downloadRuntime.getName() + "' ...", 100);
-				downloadAndInstall(selectedDirectory,
-						destinationDirectory, deleteOnExit, monitor);
-				return Status.OK_STATUS;
-			}
-			
-		};
-		downloadJob.setUser(false);
-		downloadJob.schedule();
-		IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
-		progressService.showInDialog(getActiveShell(), downloadJob);
-	}
-	
-	private IStatus downloadAndInstall(String selectedDirectory, String destinationDirectory, boolean deleteOnExit, IProgressMonitor monitor) {
-		FileInputStream in = null;
-		OutputStream out = null;
-		File file = null;
-		try {
-			URL url = new URL(downloadRuntime.getUrl());
-			String name = url.getPath();
-			int slashIdx = name.lastIndexOf('/');
-			if (slashIdx >= 0)
-				name = name.substring(slashIdx + 1);
-			
-			File destination = new File(destinationDirectory);
-			destination.mkdirs();
-			file = new File (destination, name);
-			int i = 1;
-			boolean download = true;
-			long urlModified = 0;
-			if (deleteOnExit) {
-				while (file.exists()) {
-					file = new File(destination, name + "(" + i++ + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-				}
-			} else {
-				long cacheModified = file.lastModified();
-				try {
-					urlModified = ECFExamplesTransport.getInstance()
-							.getLastModified(url);
-					download = cacheModified <= 0 || cacheModified != urlModified;
-				} catch (CoreException e) {
-					// ignore
-				}
-			}
-			if (deleteOnExit) {
-				file.deleteOnExit();
-			}
-			IStatus result = null;
-			if (download) {
-				out = new BufferedOutputStream(new FileOutputStream(file));
-				result = ECFExamplesTransport.getInstance().download(
-						file.getName(), url.toExternalForm(), out, monitor);
-				out.flush();
-				out.close();
-				if (urlModified > 0) {
-					file.setLastModified(urlModified);
-				}
-			}
-			if (monitor.isCanceled()) {
-				file.deleteOnExit();
-				file.delete();
-				return Status.CANCEL_STATUS;
-			}
-			File directory = new File(selectedDirectory);
-			directory.mkdirs();
-			if (!directory.isDirectory()) {
-				final String message = "The '" + directory + "' is not a directory.";
-				if (result != null) {
-					ProjectExamplesActivator.getDefault().getLog().log(result);
-				} else {
-					ProjectExamplesActivator.getDefault().getLog().log(result);
-				}
-				Display.getDefault().syncExec(new Runnable() {
-
-					@Override
-					public void run() {
-						MessageDialog.openError(getActiveShell(), "Error", message);
-					}
-					
-				});
-				file.deleteOnExit();
-				file.delete();
-				return Status.CANCEL_STATUS;
-			}
-			ProjectExamplesActivator.extractZipFile(file, directory, monitor);
-			if (result != null && !result.isOK()) {
-				ProjectExamplesActivator.getDefault().getLog().log(result);
-				final String message = getMessage(result);
-				Display.getDefault().syncExec(new Runnable() {
-
-					@Override
-					public void run() {
-						MessageDialog.openError(getActiveShell(), "Error", message);
-					}
-					
-				});
-				file.deleteOnExit();
-				file.delete();
-				return Status.CANCEL_STATUS;
-			}
-			String root = getRoot(file, monitor);
-			if (monitor.isCanceled()) {
-				return Status.CANCEL_STATUS;
-			}
-			if (root != null) {
-				File rootFile = new File(selectedDirectory, root);
-				if (rootFile != null && rootFile.exists()) {
-					selectedDirectory = rootFile.getAbsolutePath();
-				}
-			}
-			createRuntimes(selectedDirectory, monitor);
-		} catch (IOException e) {
-			ProjectExamplesActivator.log(e);
-			if (file != null && file.exists()) {
-				file.deleteOnExit();
-				file.delete();
-			}
-			final String message = e.getMessage();
-			Display.getDefault().syncExec(new Runnable() {
-
-				@Override
-				public void run() {
-					MessageDialog.openError(getActiveShell(), "Error", message);
-				}
-				
-			});
-		} finally {
-			if (in != null) {
-				try {
-					in.close();
-				} catch (IOException e) {
-					// ignore
-				}
-			}
-			if (out != null) {
-				try {
-					out.close();
-				} catch (IOException e) {
-					// ignore
-				}
-			}
-		}
-		return Status.OK_STATUS;
-	}
-
-	private String getMessage(IStatus result) {
-		String message;
-		if (result.getException() != null) {
-			message = result.getException().getMessage();
-		} else {
-			message = result.getMessage();
-		}
-		return message;
-	}
-	
-	private String getRoot(File file, IProgressMonitor monitor) {
-		ZipFile zipFile = null;
-		String root = null;
-		try {
-			zipFile = new ZipFile(file);
-			Enumeration<? extends ZipEntry> entries = zipFile.entries();
-			while (entries.hasMoreElements()) {
-				if (monitor.isCanceled()) {
-					return null;
-				}
-				ZipEntry entry = (ZipEntry) entries.nextElement();
-				String entryName = entry.getName();
-				if (entryName == null || entryName.isEmpty() 
-						|| entryName.startsWith(SEPARATOR) || entryName.indexOf(SEPARATOR) == -1) {
-					return null;
-				}
-				String directory = entryName.substring(0, entryName.indexOf(SEPARATOR));
-				if (root == null) {
-					root = directory;
-					continue;
-				}
-				if (!directory.equals(root)) {
-					return null;
-				}
-			}
-		} catch (IOException e) {
-			ProjectExamplesActivator.log(e);
-			return null;
-		} finally {
-			if (zipFile != null) {
-				try {
-					zipFile.close();
-				} catch (IOException e) {
-					// ignore
-				}
-			}
-		}
-		return root;
-	}
-
-	private Shell getActiveShell() {
-		Display display = Display.getDefault();
-		if (display != null) {
-			return PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
-		}
-		return null;
-	}
-
-	private static void createRuntimes(String directory,
-			IProgressMonitor monitor) {
-		JBossRuntimeLocator locator = new JBossRuntimeLocator();
-		final RuntimePath runtimePath = new RuntimePath(directory);
-		List<RuntimeDefinition> serverDefinitions = locator.searchForRuntimes(
-				runtimePath.getPath(), monitor);
-		runtimePath.getRuntimeDefinitions().clear();
-		for (RuntimeDefinition serverDefinition : serverDefinitions) {
-			serverDefinition.setRuntimePath(runtimePath);
-		}
-		runtimePath.getRuntimeDefinitions().addAll(serverDefinitions);
-		RuntimeUIActivator.getDefault().getRuntimePaths().add(runtimePath);
-		RuntimeUIActivator.getDefault().saveRuntimePaths();
-		if (serverDefinitions.size() == 0) {
-			Display.getDefault().asyncExec(new Runnable() {
-
-				@Override
-				public void run() {
-					MessageDialog.openError(Display.getDefault()
-							.getActiveShell(), "Error", "No runtime/server found...");
-				}
-			});
-		}
-		if (serverDefinitions.size() > 1) {
-			Display.getDefault().asyncExec(new Runnable() {
-				
-				@Override
-				public void run() {
-					RuntimeUIActivator.refreshRuntimes(Display.getDefault()
-							.getActiveShell(), RuntimeUIActivator.getDefault().getRuntimePaths(), null, false, 7);
-				}
-			});
-			
-		} else {
-			Set<IRuntimeDetector> detectors = RuntimeCoreActivator.getDefault()
-					.getRuntimeDetectors();
-			for (IRuntimeDetector detector : detectors) {
-				if (detector.isEnabled()) {
-					detector.initializeRuntimes(serverDefinitions);
-				}
-			}
-		}
-	}
-
-	@Override
-	protected void createButtonsForButtonBar(Composite parent) {
-		super.createButtonsForButtonBar(parent);
-		showDecorations();
-	}
-
-}

Deleted: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeViewerDialog.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeViewerDialog.java	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeViewerDialog.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -1,222 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc. 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.project.examples.dialog;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-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.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-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.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.jboss.tools.project.examples.ProjectExamplesActivator;
-import org.jboss.tools.project.examples.runtimes.DownloadRuntime;
-
-/**
- * @author snjeza
- * 
- */
-public class DownloadRuntimeViewerDialog extends Dialog {
-	
-	private TableViewer viewer;
-	private Map<String, DownloadRuntime> downloadRuntimes;
-
-	public DownloadRuntimeViewerDialog(Shell parentShell) {
-		super(parentShell);
-		setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
-				| SWT.RESIZE | getDefaultOrientation());
-		// FIXME
-		downloadRuntimes = ProjectExamplesActivator.getDefault().getDownloadRuntimes();
-	}
-
-	@Override
-	protected Control createDialogArea(Composite parent) {
-		getShell().setText("Runtimes");
-		Composite area = (Composite) super.createDialogArea(parent);
-		area.setLayout(new GridLayout());
-		Composite contents = new Composite(area, SWT.NONE);
-		GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
-		contents.setLayoutData(gd);
-		contents.setLayout(new GridLayout(1, false));
-		applyDialogFont(contents);
-		initializeDialogUnits(area);
-
-		viewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL
-				| SWT.V_SCROLL | SWT.BORDER);
-		gd = new GridData(SWT.FILL, SWT.FILL, true, true);
-		gd.heightHint = 400;
-		gd.widthHint = 700;
-		viewer.getTable().setLayoutData(gd);
-		
-		Table table = viewer.getTable();
-		table.setHeaderVisible(true);
-		table.setLinesVisible(true);
-		table.setFont(parent.getFont());
-		
-		viewer.setContentProvider(new DownloadRuntimesContentProvider());
-		
-		//String[] columnHeaders = {"Name", "ID", "Version", "URL"};
-		String[] columnHeaders = {"Name", "ID", "Version"};
-		for (int i = 0; i < columnHeaders.length; i++) {
-			TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
-			column.setLabelProvider(new DownloadRuntimesLabelProvider(i));
-			column.getColumn().setText(columnHeaders[i]);
-			column.getColumn().setResizable(true);
-			column.getColumn().setMoveable(true);
-		}
-		
-		ColumnLayoutData[] runtimePathsLayouts= {
-				new ColumnWeightData(250,250),
-				new ColumnWeightData(200,200),
-				new ColumnWeightData(150,150),
-				
-			};
-		
-		TableLayout layout = new AutoResizeTableLayout(table);
-		for (int i = 0; i < runtimePathsLayouts.length; i++) {
-			layout.addColumnData(runtimePathsLayouts[i]);
-		}
-		
-		viewer.setInput(downloadRuntimes);
-		if (downloadRuntimes.values().size() > 0) {
-			viewer.getTable().select(0);
-		}
-		viewer.getTable().setLayout(layout);
-		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-			
-			@Override
-			public void selectionChanged(SelectionChangedEvent event) {
-				validate();
-			}
-		});
-		return area;
-	}
-
-	class DownloadRuntimesContentProvider implements IStructuredContentProvider {
-
-		@Override
-		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-			
-		}
-
-		@Override
-		public Object[] getElements(Object inputElement) {
-			DownloadRuntime[] runtimes = downloadRuntimes.values().toArray(new DownloadRuntime[0]);
-			Arrays.sort(runtimes, new Comparator<DownloadRuntime>() {
-				
-				@Override
-				public int compare(DownloadRuntime o1, DownloadRuntime o2) {
-					if (o1 == null && o2 == null) {
-						return 0;
-					}
-					if (o1 == null) {
-						return 1;
-					}
-					if (o2 == null) {
-						return -1;
-					}
-					String s1 = o1.getName();
-					String s2 = o2.getName();
-					if (s1 == null && s2 == null) {
-						return 0;
-					}
-					if (s1 == null) {
-						return 1;
-					}
-					if (s2 == null) {
-						return -1;
-					}
-					return s1.compareTo(s2);
-				}
-			});
-			return runtimes;
-		}
-		
-		@Override
-		public void dispose() {
-			
-		}
-	}
-	
-	class DownloadRuntimesLabelProvider extends ColumnLabelProvider {
-
-		private int columnIndex;
-
-		public DownloadRuntimesLabelProvider(int i) {
-			this.columnIndex = i;
-		}
-
-		public String getText(Object element) {
-			if (element instanceof DownloadRuntime) {
-				DownloadRuntime downloadRuntime = (DownloadRuntime) element;
-				switch (columnIndex) {
-				case 0:
-					return downloadRuntime.getName();
-				case 1:
-					return downloadRuntime.getId();
-				case 2:
-					return downloadRuntime.getVersion();
-				case 3:
-					return downloadRuntime.getUrl();
-				}
-			}
-			return null;
-		}
-	}
-
-	@Override
-	protected void okPressed() {
-		ISelection selection = viewer.getSelection();
-		if (selection instanceof IStructuredSelection) {
-			IStructuredSelection structuredSelection = (IStructuredSelection) selection;
-			Object object = structuredSelection.getFirstElement();
-			if (object instanceof DownloadRuntime) {
-				DownloadRuntime downloadRuntime = (DownloadRuntime) object;
-				DownloadRuntimeDialog dialog = new DownloadRuntimeDialog(getShell(), downloadRuntime);
-				dialog.open();
-			}
-		}
-		super.okPressed();
-	}
-
-	@Override
-	protected void createButtonsForButtonBar(Composite parent) {
-		super.createButtonsForButtonBar(parent);
-		validate();
-	}
-
-	protected void validate() {
-		getButton(IDialogConstants.OK_ID).setEnabled(viewer.getSelection() != null);
-	}
-	
-}

Deleted: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/runtimes/DownloadRuntime.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/runtimes/DownloadRuntime.java	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/runtimes/DownloadRuntime.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -1,97 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008-2011 Red Hat, Inc. 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.project.examples.runtimes;
-
-/**
- * 
- * @author snjeza
- *
- */
-public class DownloadRuntime {
-	private String name;
-	private String id;
-	private String version;
-	private String url;
-	private boolean disclaimer = true;
-	
-	public DownloadRuntime(String id, String name, String version, String url) {
-		super();
-		this.id = id;
-		this.name = name;
-		this.version = version;
-		this.url = url;
-	}
-	
-	public String getName() {
-		return name;
-	}
-	public void setName(String name) {
-		this.name = name;
-	}
-	public String getId() {
-		return id;
-	}
-	public void setId(String id) {
-		this.id = id;
-	}
-	public String getVersion() {
-		return version;
-	}
-	public void setVersion(String version) {
-		this.version = version;
-	}
-	public String getUrl() {
-		return url;
-	}
-	public void setUrl(String url) {
-		this.url = url;
-	}
-
-	@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;
-		DownloadRuntime other = (DownloadRuntime) obj;
-		if (id == null) {
-			if (other.id != null)
-				return false;
-		} else if (!id.equals(other.id))
-			return false;
-		return true;
-	}
-
-	@Override
-	public String toString() {
-		return "DownloadRuntime [name=" + name + ", id=" + id + ", version="
-				+ version + ", url=" + url + "]";
-	}
-
-	public boolean isDisclaimer() {
-		return disclaimer;
-	}
-
-	public void setDisclaimer(boolean disclaimer) {
-		this.disclaimer = disclaimer;
-	}
-
-}

Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -54,12 +54,13 @@
 import org.eclipse.ui.dialogs.PreferencesUtil;
 import org.jboss.tools.project.examples.Messages;
 import org.jboss.tools.project.examples.ProjectExamplesActivator;
-import org.jboss.tools.project.examples.dialog.DownloadRuntimeDialog;
 import org.jboss.tools.project.examples.model.ProjectExample;
 import org.jboss.tools.project.examples.model.ProjectFix;
-import org.jboss.tools.project.examples.runtimes.DownloadRuntime;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.model.DownloadRuntime;
 import org.jboss.tools.runtime.ui.IDownloadRuntimes;
 import org.jboss.tools.runtime.ui.RuntimeUIActivator;
+import org.jboss.tools.runtime.ui.download.DownloadRuntimeDialog;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 
@@ -359,7 +360,7 @@
 	private DownloadRuntime getDownloadRuntime(ProjectFix fix) {
 		final String downloadId = fix.getProperties().get(ProjectFix.DOWNLOAD_ID);
 		if (downloadId != null) {
-			return ProjectExamplesActivator.getDefault().getDownloadRuntimes().get(downloadId);
+			return RuntimeCoreActivator.getDefault().getDownloadRuntimes().get(downloadId);
 		}
 		return null;
 	}

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF	2012-09-05 15:22:34 UTC (rev 43419)
@@ -5,10 +5,17 @@
 Bundle-Version: 2.0.0.qualifier
 Bundle-Activator: org.jboss.tools.runtime.core.RuntimeCoreActivator
 Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
- org.eclipse.core.runtime;bundle-version="3.7.0"
+ org.eclipse.core.runtime;bundle-version="3.7.0",
+ org.eclipse.equinox.p2.core;bundle-version="2.2.0",
+ org.eclipse.equinox.security;bundle-version="1.1.100",
+ org.eclipse.ecf.filetransfer;bundle-version="5.0.0",
+ org.eclipse.ecf;bundle-version="3.1.300",
+ org.eclipse.ecf.provider.filetransfer;bundle-version="3.2.0",
+ org.jboss.tools.common.core;bundle-version="3.4.0"
 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
+ org.jboss.tools.runtime.core.model,
+ org.jboss.tools.runtime.core.util

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml	2012-09-05 15:22:34 UTC (rev 43419)
@@ -2,4 +2,5 @@
 <?eclipse version="3.4"?>
 <plugin>
    <extension-point id="runtimeDetectors" name="Runtime Detectors" schema="schema/runtimeDetectors.exsd"/>
+   <extension-point id="downloadruntimes" name="Download Runtimes" schema="schema/downloadruntimes.exsd"/>
 </plugin>

Copied: trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd (from rev 43403, trunk/examples/plugins/org.jboss.tools.project.examples/schema/downloadruntimes.exsd)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd	                        (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd	2012-09-05 15:22:34 UTC (rev 43419)
@@ -0,0 +1,134 @@
+<?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="downloadruntimes" name="Download Runtimes"/>
+      </appInfo>
+      <documentation>
+         Downloads a new Runtime
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="runtime" minOccurs="1" maxOccurs="unbounded"/>
+         </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="runtime">
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="version" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="url" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="size" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="disclaimer" type="boolean">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         3.0.0
+      </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>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         JBoss by Red Hat
+      </documentation>
+   </annotation>
+
+</schema>

Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/Messages.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/Messages.java	                        (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/Messages.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -0,0 +1,32 @@
+/******************************************************************************* 
+ * Copyright (c) 2007 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 org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+	private static final String BUNDLE_NAME = "org.jboss.tools.runtime.core.Messages"; //$NON-NLS-1$
+
+	/* Standard and re-usable */
+	public static String ECFExamplesTransport_Downloading;
+	public static String ECFExamplesTransport_Internal_Error;
+	public static String ECFExamplesTransport_IO_error;
+	public static String ECFExamplesTransport_Loading;
+	public static String ECFExamplesTransport_ReceivedSize_Of_FileSize_At_RatePerSecond;
+	public static String ECFExamplesTransport_Server_redirected_too_many_times;
+
+	
+	static {
+		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+	}
+	private Messages() {
+	}
+}


Property changes on: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/Messages.java
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/Messages.properties
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/Messages.properties	                        (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/Messages.properties	2012-09-05 15:22:34 UTC (rev 43419)
@@ -0,0 +1,10 @@
+ECFExamplesTransport_Downloading=Downloading {0}
+ECFExamplesTransport_Internal_Error=Internal Error
+ECFExamplesTransport_IO_error=IO error
+ECFExamplesTransport_Loading=Loading
+# {0} = amount received (KB/MB/etc)
+# {1} = expected total (KB/MB/etc)
+# {2} = download rate per second (KB/MB/etc)
+# eg 241.73 KB of 30.95 MB (at 34.18 KB/s)
+ECFExamplesTransport_ReceivedSize_Of_FileSize_At_RatePerSecond={0} of {1} (at {2}/s) 
+ECFExamplesTransport_Server_redirected_too_many_times=Server redirected too many times


Property changes on: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/Messages.properties
___________________________________________________________________
Added: svn:executable
   + *

Modified: 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	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -10,37 +10,25 @@
  ************************************************************************************/
 package org.jboss.tools.runtime.core;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Map;
 import java.util.Set;
-import java.util.StringTokenizer;
 
-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.common.log.BasePlugin;
+import org.jboss.tools.runtime.core.model.DownloadRuntime;
 import org.jboss.tools.runtime.core.model.IRuntimeDetector;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.service.prefs.BackingStoreException;
 
 /**
  * The activator class controls the plug-in life cycle
  * 
  * @author snjeza
  */
-public class RuntimeCoreActivator extends AbstractUIPlugin {
+public class RuntimeCoreActivator extends BasePlugin {
 
 	// The plug-in ID
 	public static final String PLUGIN_ID = "org.jboss.tools.runtime.core"; //$NON-NLS-1$
 	private static final String ESB_DETECTOR_ID = "org.jboss.tools.runtime.handlers.EsbHandler"; //$NON-NLS-1$
 
-	// Preference key
-	private static final String ENABLED_DETECTORS = "enabledDetectors";
-
 	// The shared instance
 	private static RuntimeCoreActivator plugin;
 
@@ -48,8 +36,9 @@
 	private Set<IRuntimeDetector> declaredRuntimeDetectors;
 	private Set<IRuntimeDetector> runtimeDetectors;
 	private IRuntimeDetector esbDetector;
+	private Map<String, DownloadRuntime> downloadRuntimes;
 	
-	private IEclipsePreferences prefs;
+	private BundleContext context;
 	
 	/**
 	 * The constructor
@@ -64,6 +53,7 @@
 	public void start(BundleContext context) throws Exception {
 		super.start(context);
 		plugin = this;
+		this.context = context;
 	}
 
 	/*
@@ -84,6 +74,10 @@
 		return plugin;
 	}
 
+	public BundleContext getBundleContext() {
+		return context;
+	}
+	
 	public IRuntimeDetector getEsbDetector() {
 		if (esbDetector == null) {
 			for (IRuntimeDetector detector:getDeclaredRuntimeDetectors()) {
@@ -95,7 +89,16 @@
 		return esbDetector;
 	}
 
-	// Convenience method
+	/*
+	 * Is this really necessary??
+	 * 
+	 * getDeclaredRuntimeDetectors and getRuntimeDetectors
+	 * does almost exactly the same thing, except getRuntimeDetectors
+	 * sets the enablement and getDeclared... does not. 
+	 * 
+	 * Why would anyone require uninitialized detectors?
+	 * Couldn't they simply ignore the enabled flag? 
+	 */
 	public Set<IRuntimeDetector> getDeclaredRuntimeDetectors() {
 		if( declaredRuntimeDetectors == null) {
 			declaredRuntimeDetectors = RuntimeExtensionManager.getDefault().loadDeclaredRuntimeDetectors();
@@ -105,26 +108,7 @@
 	
 	public Set<IRuntimeDetector> getRuntimeDetectors() {
 		if (runtimeDetectors == null) {
-			Set<IRuntimeDetector> tmp = getDeclaredRuntimeDetectors();
-			String enabledDetectors = getPreferences().get(ENABLED_DETECTORS,
-					null);
-			if (enabledDetectors == null) {
-				saveEnabledDetectors(tmp);
-			} 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 : tmp) {
-					detector.setEnabled(enabled.contains(detector.getId()));
-				}
-			}
-			runtimeDetectors = tmp;
+			runtimeDetectors = RuntimeExtensionManager.getDefault().loadInitializedRuntimeDetectors();
 		}
 		return runtimeDetectors;
 	}
@@ -134,42 +118,12 @@
 	}
 	
 	public void saveEnabledDetectors(Set<IRuntimeDetector> allDetectors) {
-		StringBuilder builder = new StringBuilder();
-		for (IRuntimeDetector detector:allDetectors) {
-			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);
-		}
+		RuntimeCorePreferences.getDefault().saveEnabledDetectors(allDetectors);
 	}
 	
-	private  IEclipsePreferences getPreferences() {
-		if (prefs == null) {
-			prefs = ConfigurationScope.INSTANCE.getNode(PLUGIN_ID);
-		}
-		return prefs;
+	public Map<String, DownloadRuntime> getDownloadRuntimes() {
+		if( downloadRuntimes == null )
+			downloadRuntimes = RuntimeExtensionManager.getDefault().loadDownloadRuntimes();
+		return downloadRuntimes;
 	}
-	
-	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);
-	}
-	
 }

Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCorePreferences.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCorePreferences.java	                        (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCorePreferences.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -0,0 +1,58 @@
+package org.jboss.tools.runtime.core;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.osgi.service.prefs.BackingStoreException;
+
+public class RuntimeCorePreferences {	
+	// Preference key
+	private static final String ENABLED_DETECTORS = "enabledDetectors";
+	private IEclipsePreferences prefs;
+
+	private static RuntimeCorePreferences INSTANCE;
+	public static RuntimeCorePreferences getDefault() {
+		if( INSTANCE == null )
+			INSTANCE = new RuntimeCorePreferences();
+		return INSTANCE;
+	}
+	
+	public String[] getEnabledRuntimeDetectors() {
+		String enabledDetectors = getPreferences().get(ENABLED_DETECTORS,null);
+		return enabledDetectors == null ? null : enabledDetectors.split(",");
+	}
+	
+	public void saveEnabledDetectors() {
+		saveEnabledDetectors(RuntimeCoreActivator.getDefault().getDeclaredRuntimeDetectors());
+	}
+	
+	public void saveEnabledDetectors(Set<IRuntimeDetector> allDetectors) {
+		StringBuilder builder = new StringBuilder();
+		for (IRuntimeDetector detector:allDetectors) {
+			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) {
+			RuntimeCoreActivator.getDefault().logError(e);
+		}
+	}
+	
+	IEclipsePreferences getPreferences() {
+		if (prefs == null) {
+			prefs = ConfigurationScope.INSTANCE.getNode(RuntimeCoreActivator.PLUGIN_ID);
+		}
+		return prefs;
+	}
+}

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeExtensionManager.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeExtensionManager.java	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeExtensionManager.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -1,21 +1,55 @@
 package org.jboss.tools.runtime.core;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
 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.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.jboss.tools.common.util.FileUtils;
+import org.jboss.tools.runtime.core.model.DownloadRuntime;
 import org.jboss.tools.runtime.core.model.IRuntimeDetector;
 import org.jboss.tools.runtime.core.model.InvalidRuntimeDetector;
+import org.jboss.tools.runtime.core.util.ECFTransport;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 public class RuntimeExtensionManager {
+	// Extension points 
 	private static final String RUNTIME_DETECTOR_EXTENSION_ID = "org.jboss.tools.runtime.core.runtimeDetectors";
+	public static final String DOWNLOAD_RUNTIMES_EXTENSION_ID = "org.jboss.tools.runtime.ui.downloadruntimes"; //$NON-NLS-1$
 	
+	// JBoss Runtime files
+	private static final String DOWNLOAD_RUNTIMES_FILE = "download_runtime.xml"; //$NON-NLS-1$
+	private static final String JBOSS_RUNTIME_URL_DEFAULT = "http://download.jboss.org/jbosstools/examples/download_runtimes.xml"; //$NON-NLS-1$
+	private static final String JBOSS_RUNTIME_DIRECTORY = "jboss.runtime.directory.url"; //$NON-NLS-1$
+	
 	// Extension point property keys
+	
+	private static final String URL = "url"; //$NON-NLS-1$
+	private static final String DISCLAIMER = "disclaimer"; //$NON-NLS-1$
+	private static final String VERSION = "version";
 	private static final String NAME = "name";
 	private static final String PREFERENCE_ID = "preferenceId";
 	private static final String ID = "id";
@@ -29,7 +63,37 @@
 		return manager;
 	}
 	
-	// This method will do a full load and actually instantiate the classes
+	/**
+	 * This method will load runtime detectors from the extension
+	 * point, AND set its enablement based on values from the 
+	 * preferences.
+	 * 
+	 * @return
+	 */
+	public Set<IRuntimeDetector> loadInitializedRuntimeDetectors() {
+		Set<IRuntimeDetector> tmp = loadDeclaredRuntimeDetectors();
+		initializeRuntimeDetectorEnablement(tmp);
+		return tmp;
+	}
+	
+	private void initializeRuntimeDetectorEnablement(Set<IRuntimeDetector> set) {
+		String[] enabledDetectors = RuntimeCorePreferences.getDefault().getEnabledRuntimeDetectors();
+		boolean allEnabled = false;
+		if (enabledDetectors == null) {
+			allEnabled = true;
+		} 
+		List<String> enabled = Arrays.asList(enabledDetectors);
+		for (IRuntimeDetector detector : set) {
+			detector.setEnabled(allEnabled || enabled.contains(detector.getId()));
+		}
+	}
+	
+	/**
+	 *  This method will do a full load and actually instantiate the classes
+	 *  It will *NOT* set the enablement for the runtime detectors
+	 *  
+	 * @return
+	 */
 	public Set<IRuntimeDetector> loadDeclaredRuntimeDetectors() {
 		Set<IRuntimeDetector> declared = new TreeSet<IRuntimeDetector>();
 		IExtensionRegistry registry = Platform.getExtensionRegistry();
@@ -56,7 +120,7 @@
 		try {
 			detector = (IRuntimeDetector) configurationElement.createExecutableExtension("class");
 		} catch (CoreException e) {
-			RuntimeCoreActivator.log(e);
+			RuntimeCoreActivator.getDefault().logError(e);
 			detector = new InvalidRuntimeDetector();
 			detector.setValid(false);
 		}
@@ -83,4 +147,161 @@
 		detector.setPriority(priority);
 		return detector;
 	}
+	
+	public Map<String, DownloadRuntime> loadDownloadRuntimes() {
+		HashMap<String, DownloadRuntime> tmp = new HashMap<String, DownloadRuntime>();
+		loadExtensionDownloadableRuntimes(tmp);
+		loadExternalDownloadableRuntimes(tmp);
+		return tmp;
+	}
+	
+
+	public String getDownloadRuntimesURL() {
+		// use commandline override -Djboss.runtime.directory.url
+		String directory = System.getProperty(JBOSS_RUNTIME_DIRECTORY, null);
+		if (directory == null) {
+			// else use Maven-generated value (or fall back to default)
+//			ResourceBundle rb = ResourceBundle.getBundle("org.jboss.tools.project.examples.configurators.discovery"); //$NON-NLS-1$
+//			String 		url = rb.getString("runtime.url").trim(); //$NON-NLS-1$
+//			if ("".equals(url) || "${jboss.runtime.directory.url}".equals(url)){  //$NON-NLS-1$//$NON-NLS-2$
+//				//was not filtered, fallback to default value
+//				return JBOSS_RUNTIME_URL_DEFAULT;
+//			} else {
+//				return url;
+//			}
+			// Above code removed when trying to move this downloadable
+			// runtime stuff into the runtime component instead of examples / central
+			return JBOSS_RUNTIME_URL_DEFAULT;
+		}
+		return directory;		
+	}
+	
+	private File getCacheFile() {
+		IPath location = RuntimeCoreActivator.getDefault().getStateLocation();
+		File cacheFile = new File(location.toFile(), DOWNLOAD_RUNTIMES_FILE);
+		return cacheFile;
+	}
+	
+	private long getCacheModified() {
+		long cacheModified = 0;
+		// This won't be a regression. First time it will simply fetch from remote
+		File f = getCacheFile();
+		if (f.isFile()) {
+			cacheModified = f.lastModified();
+		}
+		return cacheModified;
+		
+	}
+	private URL getUrl(String s) {
+		try {
+			URL url = new URL(s);
+			return url;
+		} catch(MalformedURLException murle) {
+			return null;
+		}
+	}
+	private long getRemoteModified(String urlString) {
+		long urlModified = -1;
+		try {
+			URL url = getUrl(urlString);
+			if( url != null )
+				urlModified = ECFTransport.getInstance()
+						.getLastModified(url);
+		} catch (Exception e) {
+			RuntimeCoreActivator.getDefault().logError(e);
+			urlModified = -1;
+		}
+		return urlModified;
+	}
+	
+	private void downloadRemoteRuntimeFile(String urlString) throws Exception { 
+		URL url = getUrl(urlString);
+		File tempFile = File.createTempFile(
+				"download_runtimes", ".xml");  //$NON-NLS-1$//$NON-NLS-2$
+		tempFile.deleteOnExit();
+		OutputStream destination = new FileOutputStream(tempFile);
+		IStatus status = ECFTransport.getInstance().download(
+				DOWNLOAD_RUNTIMES_FILE, urlString, destination,
+				new NullProgressMonitor());
+		if (status.isOK() && url != null) {
+			long cacheModified = ECFTransport.getInstance()
+					.getLastModified(url);
+			FileUtils.copyFile(tempFile, getCacheFile());
+			tempFile.delete();
+			getCacheFile().setLastModified(cacheModified);
+		} else {
+			RuntimeCoreActivator.getDefault().getLog().log(status);
+		}
+	}
+	
+	private void loadExtensionDownloadableRuntimes(HashMap<String, DownloadRuntime> map) {
+		IExtensionRegistry registry = Platform.getExtensionRegistry();
+		IExtensionPoint extensionPoint = registry
+				.getExtensionPoint(DOWNLOAD_RUNTIMES_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];
+				String name = configurationElement.getAttribute(NAME);
+				String id = configurationElement.getAttribute(ID);
+				String version = configurationElement.getAttribute(VERSION);
+				String url = configurationElement.getAttribute(URL);
+				String disclaimer = configurationElement.getAttribute(DISCLAIMER);
+				DownloadRuntime downloadRuntime = new DownloadRuntime(id, name, version, url);
+				if (Boolean.FALSE.toString().equals(disclaimer)) {
+					downloadRuntime.setDisclaimer(false);
+				}
+				map.put(id, downloadRuntime);
+			}
+		}
+	}
+	private void loadExternalDownloadableRuntimes(HashMap<String, DownloadRuntime> map) {
+		try {
+			String urlString = getDownloadRuntimesURL();
+			if (getCacheModified() == 0 || getRemoteModified(urlString) != getCacheModified()) {
+				downloadRemoteRuntimeFile(urlString);
+			}
+		} catch (Exception e) {
+			RuntimeCoreActivator.getDefault().logError(e);
+		}
+		File cacheFile = getCacheFile();
+		if (cacheFile != null && cacheFile.isFile()) {
+			try {
+				DocumentBuilderFactory dbf = DocumentBuilderFactory
+						.newInstance();
+				DocumentBuilder db = dbf.newDocumentBuilder();
+				Document doc = db.parse(cacheFile);
+				NodeList runtimes = doc.getElementsByTagName("runtime"); //$NON-NLS-1$
+				int len = runtimes.getLength();
+				for (int i = 0; i < len; i++) {
+					Node node = runtimes.item(i);
+					if (node.getNodeType() == Node.ELEMENT_NODE) {
+						Element element = (Element) node;
+						String id = element.getAttribute("id"); //$NON-NLS-1$
+						String name = element.getAttribute("name"); //$NON-NLS-1$
+						String version = element.getAttribute("version"); //$NON-NLS-1$
+						String url = element.getAttribute("url"); //$NON-NLS-1$
+						String disclaimer = element.getAttribute("disclaimer"); //$NON-NLS-1$
+						if (id == null || name == null || version == null || url == null) {
+							IStatus status = new Status(IStatus.WARNING, 
+									RuntimeCoreActivator.PLUGIN_ID,
+									"Invalid runtime: id=" + id + ",name=" + 
+											name + ",version=" + version + ",url=" + url);
+							RuntimeCoreActivator.getDefault().getLog().log(status);
+						} else {
+							DownloadRuntime runtime = new DownloadRuntime(id, name, version, url);
+							runtime.setDisclaimer("true".equals(disclaimer)); //$NON-NLS-1$
+							map.put(id, runtime);
+						}
+					}
+				}
+			} catch (Exception e) {
+				RuntimeCoreActivator.getDefault().logError(e);
+			} 
+		}
+	}
+
 }

Copied: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java (from rev 43403, trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/runtimes/DownloadRuntime.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java	                        (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -0,0 +1,97 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. 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;
+
+/**
+ * 
+ * @author snjeza
+ *
+ */
+public class DownloadRuntime {
+	private String name;
+	private String id;
+	private String version;
+	private String url;
+	private boolean disclaimer = true;
+	
+	public DownloadRuntime(String id, String name, String version, String url) {
+		super();
+		this.id = id;
+		this.name = name;
+		this.version = version;
+		this.url = url;
+	}
+	
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	public String getId() {
+		return id;
+	}
+	public void setId(String id) {
+		this.id = id;
+	}
+	public String getVersion() {
+		return version;
+	}
+	public void setVersion(String version) {
+		this.version = version;
+	}
+	public String getUrl() {
+		return url;
+	}
+	public void setUrl(String url) {
+		this.url = url;
+	}
+
+	@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;
+		DownloadRuntime other = (DownloadRuntime) obj;
+		if (id == null) {
+			if (other.id != null)
+				return false;
+		} else if (!id.equals(other.id))
+			return false;
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "DownloadRuntime [name=" + name + ", id=" + id + ", version="
+				+ version + ", url=" + url + "]";
+	}
+
+	public boolean isDisclaimer() {
+		return disclaimer;
+	}
+
+	public void setDisclaimer(boolean disclaimer) {
+		this.disclaimer = disclaimer;
+	}
+
+}

Copied: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/util/ECFTransport.java (from rev 43403, trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/util/ECFTransport.java	                        (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/util/ECFTransport.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -0,0 +1,531 @@
+package org.jboss.tools.runtime.core.util;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.ProtocolException;
+import java.net.URL;
+import java.net.URLEncoder;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerFactory;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.security.ConnectContextFactory;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.filetransfer.IFileTransferListener;
+import org.eclipse.ecf.filetransfer.IIncomingFileTransfer;
+import org.eclipse.ecf.filetransfer.IRemoteFile;
+import org.eclipse.ecf.filetransfer.IRemoteFileSystemBrowserContainerAdapter;
+import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener;
+import org.eclipse.ecf.filetransfer.IRetrieveFileTransferContainerAdapter;
+import org.eclipse.ecf.filetransfer.IncomingFileTransferException;
+import org.eclipse.ecf.filetransfer.RemoteFileSystemException;
+import org.eclipse.ecf.filetransfer.UserCancelledException;
+import org.eclipse.ecf.filetransfer.events.IFileTransferEvent;
+import org.eclipse.ecf.filetransfer.events.IIncomingFileTransferReceiveDataEvent;
+import org.eclipse.ecf.filetransfer.events.IIncomingFileTransferReceiveDoneEvent;
+import org.eclipse.ecf.filetransfer.events.IIncomingFileTransferReceiveStartEvent;
+import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent;
+import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemEvent;
+import org.eclipse.ecf.filetransfer.identity.FileCreateException;
+import org.eclipse.ecf.filetransfer.identity.FileIDFactory;
+import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory;
+import org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer;
+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.UIServices;
+import org.eclipse.equinox.p2.core.UIServices.AuthenticationInfo;
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
+import org.eclipse.equinox.security.storage.StorageException;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.runtime.core.Messages;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @author snjeza
+ * based on org.eclipse.equinox.internal.p2.updatesite.ECFTransport
+ * 
+ */
+public class ECFTransport {
+	
+	/**
+	 * The number of password retry attempts allowed before failing.
+	 */
+	private static final int LOGIN_RETRIES = 3;
+	private static final ProtocolException ERROR_401 = new ProtocolException();
+	private static final String SERVER_REDIRECT = Messages.ECFExamplesTransport_Server_redirected_too_many_times;
+	
+	/**
+	 * The node identifier for repository secure preference store.
+	 */
+	public static final String PREFERENCE_NODE = "org.jboss.tools.project.examples"; //$NON-NLS-1$
+
+	/**
+	 * The key for a string property providing the user name to an authenticated
+	 * URL.  This key is used in the secure preference store for repository data.
+	 * @see #PREFERENCE_NODE
+	 */
+	public static final String PROP_USERNAME = "username"; //$NON-NLS-1$
+
+	/**
+	 * The key for a string property providing the password to an authenticated
+	 * URL.  This key is used in the secure preference store for repository data.
+	 * @see #PREFERENCE_NODE
+	 */
+	public static final String PROP_PASSWORD = "password"; //$NON-NLS-1$
+
+	private static ECFTransport INSTANCE;
+	private ServiceTracker retrievalFactoryTracker;
+	
+	/**
+	 * A job that waits on a barrier.
+	 */
+	static class WaitJob extends Job {
+		private final Object[] barrier;
+
+		/**
+		 * Creates a wait job.
+		 * @param location A location string that is used in the job name
+		 * @param barrier The job will wait until the first entry in the barrier is non-null
+		 */
+		WaitJob(String location, Object[] barrier) {
+			super(Messages.ECFExamplesTransport_Loading);
+			this.barrier = barrier;
+			setSystem(true);
+		}
+
+		/* (non-Javadoc)
+		 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+		 */
+		protected IStatus run(IProgressMonitor monitor) {
+			synchronized (barrier) {
+				while (barrier[0] == null) {
+					try {
+						barrier.wait();
+					} catch (InterruptedException e) {
+						//ignore
+					}
+				}
+			}
+			return Status.OK_STATUS;
+		}
+	}
+
+	/**
+	 * Private to avoid client instantiation.
+	 */
+	private ECFTransport() {
+	}
+	
+	/**
+	 * Returns an initialized instance of ECFExamplesTransport
+	 */
+	public static synchronized ECFTransport getInstance() {
+		if (INSTANCE == null) {
+			INSTANCE = new ECFTransport();
+		}
+		return INSTANCE;
+	}
+	
+	/**
+	 * Gets the last modified date for the specified file.
+	 * @param location - The URL location of the file.
+	 * @return A <code>long</code> representing the date. Returns <code>0</code> if the file is not found or an error occurred.
+	 * @exception OperationCanceledException if the request was canceled.
+	 */
+	public long getLastModified(URL location) throws CoreException {
+		String locationString = location.toExternalForm();
+		try {
+			IConnectContext context = getConnectionContext(locationString, false);
+			for (int i = 0; i < LOGIN_RETRIES; i++) {
+				try {
+					return doGetLastModified(locationString, context);
+				} catch (ProtocolException e) {
+					if (ERROR_401 == e)
+						context = getConnectionContext(locationString, true);
+				} catch (Exception e) {
+					e.getMessage();
+				}
+			}
+		} catch (UserCancelledException e) {
+			throw new OperationCanceledException();
+		}
+		//too many retries, so report as failure
+		throw new CoreException(new Status(IStatus.ERROR, RuntimeCoreActivator.PLUGIN_ID, Messages.ECFExamplesTransport_IO_error, null));
+	}
+	
+	/**
+	 * Perform the ECF call to get the last modified time, failing if there is any
+	 * protocol failure such as an authentication failure.
+	 */
+	private long doGetLastModified(String location, IConnectContext context) throws ProtocolException {
+		IContainer container;
+		try {
+			container = ContainerFactory.getDefault().createContainer();
+		} catch (ContainerCreateException e) {
+			return 0;
+		}
+		IRemoteFileSystemBrowserContainerAdapter adapter = (IRemoteFileSystemBrowserContainerAdapter) container.getAdapter(IRemoteFileSystemBrowserContainerAdapter.class);
+		if (adapter == null) {
+			return 0;
+		}
+		IRemoteFile remoteFile = checkFile(adapter, location, context);
+		if (remoteFile == null) {
+			return 0;
+		}
+		return remoteFile.getInfo().getLastModified();
+	}
+	
+	/**
+	 * Downloads the contents of the given URL to the given output stream. The
+	 * destination stream will be closed by this method whether it succeeds
+	 * to download or not.
+	 */
+	public IStatus download(String name, String url, OutputStream destination, IProgressMonitor monitor) {
+		IStatus status = null;
+		try {
+			IConnectContext context = getConnectionContext(url, false);
+			for (int i = 0; i < LOGIN_RETRIES; i++) {
+				try {
+					status = performDownload(name,url, destination, context, monitor);
+					if (status.isOK()) {
+						return status;
+					} else {
+						Throwable exception = status.getException();
+						if (exception instanceof IncomingFileTransferException) {
+							int code = ((IncomingFileTransferException)exception).getErrorCode();
+							if (code == 401) {
+								context = getConnectionContext(url, true);
+							}
+						}
+					}
+				} catch (ProtocolException e) {
+					if (e == ERROR_401)
+						context = getConnectionContext(url, true);
+				}
+			}
+		} catch (UserCancelledException e) {
+			return Status.CANCEL_STATUS;
+		} catch (CoreException e) {
+			return e.getStatus();
+		} finally {
+			try {
+				destination.close();
+			} catch (IOException e) {
+				//ignore secondary failure
+			}
+		}
+		//reached maximum number of retries without success
+		if (status != null) {
+			return status;
+		}
+		return new Status(IStatus.ERROR, RuntimeCoreActivator.PLUGIN_ID,  Messages.ECFExamplesTransport_IO_error, null);
+	}
+
+	public IStatus performDownload(String name,String toDownload, OutputStream target, IConnectContext context, IProgressMonitor monitor) throws ProtocolException {
+		IRetrieveFileTransferFactory factory = (IRetrieveFileTransferFactory) getFileTransferServiceTracker().getService();
+		if (factory == null)
+			return new Status(IStatus.ERROR, RuntimeCoreActivator.PLUGIN_ID, Messages.ECFExamplesTransport_IO_error);
+
+		return transfer(name,factory.newInstance(), toDownload, target, context, monitor);
+	}
+
+	private IStatus transfer(final String name,final IRetrieveFileTransferContainerAdapter retrievalContainer, final String toDownload, final OutputStream target, IConnectContext context, final IProgressMonitor monitor) throws ProtocolException {
+		final IStatus[] result = new IStatus[1];
+		IFileTransferListener listener = new IFileTransferListener() {
+			private long transferStartTime;
+			protected int oldWorked;
+
+			public void handleTransferEvent(IFileTransferEvent event) {
+				if (event instanceof IIncomingFileTransferReceiveStartEvent) {
+					IIncomingFileTransferReceiveStartEvent rse = (IIncomingFileTransferReceiveStartEvent) event;
+					try {
+						if (target != null) {
+							rse.receive(target);
+							transferStartTime = System.currentTimeMillis();
+						}
+						if (monitor != null) {
+							long fileLength = rse.getSource().getFileLength();
+							final long totalWork = ((fileLength == -1) ? 100 : fileLength);
+							int work = (totalWork > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) totalWork;
+							monitor.beginTask(NLS.bind(Messages.ECFExamplesTransport_Downloading, name), work);
+							oldWorked=0;
+						}
+					} catch (IOException e) {
+						IStatus status = convertToStatus(e);
+						synchronized (result) {
+							result[0] = status;
+							result.notify();
+						}
+					}
+				}
+				if (event instanceof IIncomingFileTransferReceiveDataEvent) {
+					IIncomingFileTransfer source = ((IIncomingFileTransferReceiveDataEvent) event).getSource();
+					if (monitor != null) {
+						if (monitor.isCanceled()) {
+							try {
+								source.cancel();
+							} catch (Throwable e) {
+								IStatus status = new Status(IStatus.WARNING, RuntimeCoreActivator.PLUGIN_ID,"Operation canceled");
+								RuntimeCoreActivator.getDefault().getLog().log(status);
+							}
+							return;
+						}
+						long fileLength = source.getFileLength();
+						final long totalWork = ((fileLength == -1) ? 100 : fileLength);
+						double factor = (totalWork > Integer.MAX_VALUE) ? (((double) Integer.MAX_VALUE) / ((double) totalWork)) : 1.0;
+						long received = source.getBytesReceived();
+						int worked = (int) Math.round(factor * received);
+						double downloadRateBytesPerSecond = (received / ((System.currentTimeMillis() + 1 - transferStartTime) / 1000.0));
+						
+						String downloadRateString = AbstractRetrieveFileTransfer.toHumanReadableBytes(downloadRateBytesPerSecond);
+						String receivedString = AbstractRetrieveFileTransfer.toHumanReadableBytes(received);
+						String fileLengthString = AbstractRetrieveFileTransfer.toHumanReadableBytes(fileLength);
+						monitor.subTask(NLS.bind(
+								Messages.ECFExamplesTransport_ReceivedSize_Of_FileSize_At_RatePerSecond, 
+									new String[]{receivedString, fileLengthString, downloadRateString}));
+						monitor.worked(worked-oldWorked);
+						oldWorked=worked;
+					}
+				}
+				if (event instanceof IIncomingFileTransferReceiveDoneEvent) {
+					Exception exception = ((IIncomingFileTransferReceiveDoneEvent) event).getException();
+					IStatus status = convertToStatus(exception);
+					synchronized (result) {
+						result[0] = status;
+						result.notify();
+					}
+				}
+			}
+		};
+
+		try {
+			retrievalContainer.setConnectContextForAuthentication(context);
+			retrievalContainer.sendRetrieveRequest(FileIDFactory.getDefault().createFileID(retrievalContainer.getRetrieveNamespace(), toDownload), listener, null);
+		} catch (IncomingFileTransferException e) {
+			IStatus status = e.getStatus();
+			Throwable exception = status.getException();
+			if (exception instanceof IOException) {
+				if (exception.getMessage() != null && (exception.getMessage().indexOf("401") != -1 || exception.getMessage().indexOf(SERVER_REDIRECT) != -1)) //$NON-NLS-1$
+					throw ERROR_401;
+			}
+			return status;
+		} catch (FileCreateException e) {
+			return e.getStatus();
+		}
+		waitFor(toDownload, result);
+		return result[0];
+	}
+
+	private IRemoteFile checkFile(final IRemoteFileSystemBrowserContainerAdapter retrievalContainer, final String location, IConnectContext context) throws ProtocolException {
+		final Object[] result = new Object[2];
+		final Object FAIL = new Object();
+		IRemoteFileSystemListener listener = new IRemoteFileSystemListener() {
+			public void handleRemoteFileEvent(IRemoteFileSystemEvent event) {
+				Exception exception = event.getException();
+				if (exception != null) {
+					synchronized (result) {
+						result[0] = FAIL;
+						result[1] = exception;
+						result.notify();
+					}
+				} else if (event instanceof IRemoteFileSystemBrowseEvent) {
+					IRemoteFileSystemBrowseEvent fsbe = (IRemoteFileSystemBrowseEvent) event;
+					IRemoteFile[] remoteFiles = fsbe.getRemoteFiles();
+					if (remoteFiles != null && remoteFiles.length > 0 && remoteFiles[0] != null) {
+						synchronized (result) {
+							result[0] = remoteFiles[0];
+							result.notify();
+						}
+					} else {
+						synchronized (result) {
+							result[0] = FAIL;
+							result.notify();
+						}
+					}
+				}
+			}
+		};
+		try {
+			retrievalContainer.setConnectContextForAuthentication(context);
+			retrievalContainer.sendBrowseRequest(FileIDFactory.getDefault().createFileID(retrievalContainer.getBrowseNamespace(), location), listener);
+		} catch (RemoteFileSystemException e) {
+			return null;
+		} catch (FileCreateException e) {
+			return null;
+		}
+		waitFor(location, result);
+		if (result[0] == FAIL && result[1] instanceof IOException) {
+			IOException ioException = (IOException) result[1];
+			//throw a special exception for authentication failure so we know to prompt for username/password
+			String message = ioException.getMessage();
+			if (message != null && (message.indexOf(" 401 ") != -1 || message.indexOf(SERVER_REDIRECT) != -1)) //$NON-NLS-1$
+				throw ERROR_401;
+		}
+		if (result[0] instanceof IRemoteFile)
+			return (IRemoteFile) result[0];
+		return null;
+	}
+
+	
+	/**
+	 * Returns the connection context for the given URL. This may prompt the
+	 * user for user name and password as required.
+	 * 
+	 * @param xmlLocation - the file location requiring login details
+	 * @param prompt - use <code>true</code> to prompt the user instead of
+	 * looking at the secure preference store for login, use <code>false</code>
+	 * to only try the secure preference store
+	 * @throws UserCancelledException when the user cancels the login prompt 
+	 * @throws CoreException if the password cannot be read or saved
+	 * @return The connection context
+	 */
+	public IConnectContext getConnectionContext(String xmlLocation, boolean prompt) throws UserCancelledException, CoreException {
+		ISecurePreferences securePreferences = SecurePreferencesFactory.getDefault();
+		IPath hostLocation = new Path(xmlLocation).removeLastSegments(1);
+		String nodeKey;
+		try {
+			nodeKey = URLEncoder.encode(hostLocation.toString(), "UTF-8"); //$NON-NLS-1$
+		} catch (UnsupportedEncodingException e2) {
+			//fall back to default platform encoding
+			nodeKey = URLEncoder.encode(hostLocation.toString());
+		}
+		String nodeName = PREFERENCE_NODE + '/' + nodeKey;
+		ISecurePreferences prefNode = null;
+		if (securePreferences.nodeExists(nodeName))
+			prefNode = securePreferences.node(nodeName);
+		if (!prompt) {
+			if (prefNode == null)
+				return null;
+			try {
+				String username = prefNode.get(PROP_USERNAME, null);
+				String password = prefNode.get(PROP_PASSWORD, null);
+				//if we don't have stored connection data just return a null connection context
+				if (username == null || password == null)
+					return null;
+				return ConnectContextFactory.createUsernamePasswordConnectContext(username, password);
+			} catch (StorageException e) {
+				String msg = Messages.ECFExamplesTransport_Internal_Error;
+				throw new CoreException(new Status(IStatus.ERROR, RuntimeCoreActivator.PLUGIN_ID, msg, e));
+			}
+		}
+		//need to prompt user for user name and password
+		// check if adminUIService has been started
+		Bundle bundle = Platform.getBundle("org.eclipse.equinox.p2.ui.sdk"); //$NON-NLS-1$
+		if (bundle != null && bundle.getState() != Bundle.ACTIVE) {
+			try {
+				bundle.start();
+			} catch (BundleException e) {
+				// ignore
+			}
+		}
+		IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(RuntimeCoreActivator.getDefault().getBundleContext(), IProvisioningAgent.SERVICE_NAME);
+		UIServices adminUIService = (UIServices) agent.getService(UIServices.SERVICE_NAME);
+		AuthenticationInfo loginDetails = null;
+		if (adminUIService != null)
+			loginDetails = adminUIService.getUsernamePassword(hostLocation.toString());
+		//null result means user canceled password dialog
+		if (loginDetails == null)
+			throw new UserCancelledException();
+		//save user name and password if requested by user
+		if (loginDetails.saveResult()) {
+			if (prefNode == null)
+				prefNode = securePreferences.node(nodeName);
+			try {
+				prefNode.put(PROP_USERNAME, loginDetails.getUserName(), true);
+				prefNode.put(PROP_PASSWORD, loginDetails.getPassword(), true);
+				prefNode.flush();
+			} catch (StorageException e1) {
+				String msg = Messages.ECFExamplesTransport_Internal_Error;
+				throw new CoreException(new Status(IStatus.ERROR, RuntimeCoreActivator.PLUGIN_ID,  msg, e1));
+			} catch (IOException e) {
+				String msg = Messages.ECFExamplesTransport_Internal_Error;
+				throw new CoreException(new Status(IStatus.ERROR, RuntimeCoreActivator.PLUGIN_ID, msg, e));
+			}
+		}
+		return ConnectContextFactory.createUsernamePasswordConnectContext(loginDetails.getUserName(), loginDetails.getPassword());
+	}
+
+	private IStatus convertToStatus(Exception e) {
+		if (e == null)
+			return Status.OK_STATUS;
+		if (e instanceof UserCancelledException)
+			return new Status(IStatus.CANCEL, RuntimeCoreActivator.PLUGIN_ID, e.getMessage(), e);
+		return new Status(IStatus.ERROR, RuntimeCoreActivator.PLUGIN_ID, e.getMessage(), e);
+	}
+
+	/**
+	 * Waits until the first entry in the given array is non-null.
+	 */
+	private void waitFor(String location, Object[] barrier) {
+		WaitJob wait = new WaitJob(location, barrier);
+		wait.schedule();
+		while (barrier[0] == null) {
+			boolean logged = false;
+			try {
+				wait.join();
+			} catch (InterruptedException e) {
+				if (!logged)
+					RuntimeCoreActivator.getDefault().logError(e);
+			}
+		}
+	}
+	
+	private synchronized ServiceTracker getFileTransferServiceTracker() {
+		if (retrievalFactoryTracker == null) {
+			retrievalFactoryTracker = new ServiceTracker(RuntimeCoreActivator.getDefault().getBundleContext(), IRetrieveFileTransferFactory.class.getName(), null);
+			retrievalFactoryTracker.open();
+			startBundle("org.eclipse.ecf"); //$NON-NLS-1$
+			startBundle("org.eclipse.ecf.provider.filetransfer"); //$NON-NLS-1$
+		}
+		return retrievalFactoryTracker;
+	}
+	
+	private boolean startBundle(String bundleId) {
+		PackageAdmin packageAdmin = (PackageAdmin) ServiceHelper.getService(RuntimeCoreActivator.getDefault().getBundleContext(), PackageAdmin.class.getName());
+		if (packageAdmin == null)
+			return false;
+
+		Bundle[] bundles = packageAdmin.getBundles(bundleId, null);
+		if (bundles != null && bundles.length > 0) {
+			for (int i = 0; i < bundles.length; i++) {
+				try {
+					if ((bundles[i].getState() & Bundle.INSTALLED) == 0) {
+						bundles[i].start(Bundle.START_ACTIVATION_POLICY);
+						bundles[i].start(Bundle.START_TRANSIENT);
+						return true;
+					}
+				} catch (BundleException e) {
+					// failed, try next bundle
+				}
+			}
+		}
+		return false;
+	}
+
+	public static Object getService(BundleContext context, String name) {
+		if (context == null)
+			return null;
+		ServiceReference reference = context.getServiceReference(name);
+		if (reference == null)
+			return null;
+		Object result = context.getService(reference);
+		context.ungetService(reference);
+		return result;
+	}
+}

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF	2012-09-05 15:22:34 UTC (rev 43419)
@@ -8,11 +8,18 @@
  org.eclipse.core.runtime,
  org.jboss.tools.runtime.core,
  org.eclipse.core.resources,
- org.eclipse.ui.navigator;bundle-version="3.5.100"
+ org.eclipse.ui.navigator;bundle-version="3.5.100",
+ org.eclipse.ecf.filetransfer;bundle-version="5.0.0",
+ org.eclipse.ecf.provider.filetransfer;bundle-version="3.2.0",
+ org.eclipse.ecf;bundle-version="3.1.300",
+ org.eclipse.equinox.security;bundle-version="1.1.100",
+ org.eclipse.equinox.p2.core;bundle-version="2.2.0",
+ org.jboss.tools.common.core;bundle-version="3.4.0"
 Bundle-ActivationPolicy: lazy
 Bundle-Localization: plugin
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-Vendor: %BundleVendor
 Export-Package: org.jboss.tools.runtime.ui,
  org.jboss.tools.runtime.ui.dialogs,
+ org.jboss.tools.runtime.ui.download,
  org.jboss.tools.runtime.ui.preferences

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.xml	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/plugin.xml	2012-09-05 15:22:34 UTC (rev 43419)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.4"?>
 <plugin>
+   <extension-point id="downloadruntimes" name="downloadruntimes" schema="schema/downloadruntimes.exsd"/>
 
    <extension
         point="org.eclipse.ui.preferencePages">

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -1,8 +1,8 @@
 package org.jboss.tools.runtime.ui;
 
-import org.eclipse.swt.widgets.Shell;
+import java.util.HashMap;
 
 public interface IDownloadRuntimes {
 
-	void execute(Shell shell);
+	void execute(HashMap<String, Object> data);
 }

Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -22,14 +22,12 @@
 import java.util.List;
 import java.util.Set;
 
-import org.eclipse.core.internal.preferences.PrefsMessages;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.ListenerList;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.preferences.ConfigurationScope;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.preference.PreferenceDialog;
@@ -54,8 +52,8 @@
 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.RuntimeDefinition;
 import org.jboss.tools.runtime.core.model.RuntimePath;
-import org.jboss.tools.runtime.core.model.RuntimeDefinition;
 import org.jboss.tools.runtime.ui.dialogs.SearchRuntimePathDialog;
 import org.jboss.tools.runtime.ui.preferences.RuntimePreferencePage;
 import org.osgi.framework.BundleContext;
@@ -112,17 +110,25 @@
 	
 	private static final String RUNTIME_PREFERENCES_VERSION = "2"; //$NON-NLS-1$
 
+	private BundleContext context;
+	
 	private Set<RuntimePath> runtimePaths = new HashSet<RuntimePath>();
 	
 	private List<RuntimeDefinition> serverDefinitions;
 	
 	private ListenerList runtimePathChangeChangeListeners;
+	
+
 	/**
 	 * The constructor
 	 */
 	public RuntimeUIActivator() {
 	}
 
+	public BundleContext getBundleContext() {
+		return context;
+	}
+
 	/*
 	 * (non-Javadoc)
 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
@@ -131,6 +137,7 @@
 		super.start(context);
 		plugin = this;
 		runtimePaths = null;
+		this.context = context;
 	}
 
 	/*

Copied: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeDialog.java (from rev 43403, trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeDialog.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeDialog.java	                        (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeDialog.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -0,0 +1,597 @@
+/*************************************************************************************
+ * Copyright (c) 2010-2011 Red Hat, Inc. 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.download;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.runtime.CoreException;
+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.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.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+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.Display;
+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.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.ui.progress.IProgressService;
+import org.jboss.tools.common.zip.UnzipOperation;
+import org.jboss.tools.runtime.core.JBossRuntimeLocator;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.model.DownloadRuntime;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.RuntimeDefinition;
+import org.jboss.tools.runtime.core.model.RuntimePath;
+import org.jboss.tools.runtime.core.util.ECFTransport;
+import org.jboss.tools.runtime.ui.RuntimeUIActivator;
+
+/**
+ * @author snjeza
+ * 
+ */
+public class DownloadRuntimeDialog extends Dialog {
+
+	private static final String SEPARATOR = "/"; //$NON-NLS-1$
+	private static final String FOLDER_IS_REQUIRED = "This folder is required";
+	private static final String FOLDER_IS_NOT_WRITABLE = "This folder does not exist or is not writable";
+	private static final String DELETE_ON_EXIT = "deleteOnExit"; //$NON-NLS-1$
+	private static final String JAVA_IO_TMPDIR = "java.io.tmpdir"; //$NON-NLS-1$
+	private static final String USER_HOME = "user.home"; //$NON-NLS-1$
+	private static final String DEFAULT_DIALOG_PATH = "defaultDialogPath"; //$NON-NLS-1$
+	private static final String DEFAULT_DESTINATION_PATH = "defaultDestinationPath"; //$NON-NLS-1$
+	private IDialogSettings dialogSettings;
+	private Button deleteOnExit;
+	private Text destinationPathText;
+	private Text pathText;
+	private DownloadRuntime downloadRuntime;
+	private String delete;
+	private ControlDecoration decPathError;
+	private ControlDecoration decPathReq;
+	private ControlDecoration destinationPathError;
+	private ControlDecoration destinationPathReq;
+	
+	public DownloadRuntimeDialog(Shell parentShell, DownloadRuntime downloadRuntime) {
+		super(parentShell);
+		setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
+				| SWT.RESIZE | getDefaultOrientation());
+		dialogSettings = RuntimeUIActivator.getDefault().getDialogSettings();
+		this.downloadRuntime = downloadRuntime;
+	}
+
+	@Override
+	protected Control createDialogArea(Composite parent) {
+		getShell().setText("Download Runtime '" + downloadRuntime.getName() + "'");
+		Composite area = (Composite) super.createDialogArea(parent);
+		Composite contents = new Composite(area, SWT.NONE);
+		GridData gd = new GridData(GridData.FILL_BOTH);
+		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));
+		
+		if (downloadRuntime.isDisclaimer()) {
+			Group disclaimerComposite = new Group(pathComposite, SWT.NONE);
+			gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+			gd.horizontalSpan = 3;
+			disclaimerComposite.setLayoutData(gd);
+			disclaimerComposite.setLayout(new GridLayout(1, false));
+			disclaimerComposite.setText("Warning");
+			new Label(disclaimerComposite, SWT.NONE).setText("This is a community project and, as such is not supported with an SLA.");
+			Link link = new Link(disclaimerComposite, SWT.NONE);
+			link.setText("If you're looking for fully supported, certified, enterprise middleware try JBoss Enterprise Middleware products. <a>Show Details</a>");
+
+			link.addSelectionListener( new SelectionAdapter( ) {
+
+				public void widgetSelected( SelectionEvent e )
+				{
+					String text = e.text;
+					if ("Show Details".equals(text)) {
+						IWorkbenchBrowserSupport support = PlatformUI.getWorkbench()
+								.getBrowserSupport();
+						try {
+							URL url = new URL("http://www.redhat.com/jboss/"); //$NON-NLS-1$
+							support.getExternalBrowser().openURL(url);
+						} catch (Exception e1) {
+							RuntimeUIActivator.log(e1);
+						}
+					}
+					
+				}
+			} );
+		}
+		Label urlLabel = new Label(pathComposite, SWT.NONE);
+		urlLabel.setText("URL:");
+		Text urlText = new Text(pathComposite, SWT.READ_ONLY|SWT.BORDER);
+		gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+		gd.horizontalSpan=2;
+		urlText.setLayoutData(gd);
+		urlText.setText(downloadRuntime.getUrl());
+		Label pathLabel = new Label(pathComposite, SWT.NONE);
+		pathLabel.setText("Install folder:");
+		
+		pathText = new Text(pathComposite, SWT.BORDER);
+		gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+		pathText.setLayoutData(gd);
+		final String defaultPath = getDefaultPath();
+		pathText.setText(defaultPath);
+		decPathError = addDecoration(pathText, FieldDecorationRegistry.DEC_ERROR, FOLDER_IS_NOT_WRITABLE);
+		decPathReq = addDecoration(pathText, FieldDecorationRegistry.DEC_REQUIRED, FOLDER_IS_REQUIRED);
+		pathText.addModifyListener(new ModifyListener() {
+			
+			@Override
+			public void modifyText(ModifyEvent e) {
+				validate();
+			}
+		});
+		
+		Button browseButton = new Button(pathComposite, SWT.NONE);
+		browseButton.setText("Browse...");
+		browseButton.addSelectionListener(new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				DirectoryDialog dialog = new DirectoryDialog(getShell());
+				dialog.setMessage("Select install folder");
+				dialog.setFilterPath(pathText.getText());
+				final String path = dialog.open();
+				if (path == null) {
+					return;
+				}
+				pathText.setText(path);
+			}
+		
+		});
+		
+		Label destinationLabel = new Label(pathComposite, SWT.NONE);
+		destinationLabel.setText("Download folder:");
+		
+		destinationPathText = new Text(pathComposite, SWT.BORDER);
+		gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+		destinationPathText.setLayoutData(gd);
+		String destinationPath = dialogSettings.get(DEFAULT_DESTINATION_PATH);
+		destinationPathError = addDecoration(destinationPathText, FieldDecorationRegistry.DEC_ERROR, FOLDER_IS_NOT_WRITABLE);
+		destinationPathReq = addDecoration(destinationPathText, FieldDecorationRegistry.DEC_REQUIRED, FOLDER_IS_REQUIRED);
+		
+		if (destinationPath == null || destinationPath.isEmpty()) {
+			destinationPath=System.getProperty(JAVA_IO_TMPDIR);
+		}
+		destinationPathText.setText(destinationPath);
+		Button browseDestinationButton = new Button(pathComposite, SWT.NONE);
+		browseDestinationButton.setText("Browse...");
+		browseDestinationButton.addSelectionListener(new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				DirectoryDialog dialog = new DirectoryDialog(getShell());
+				dialog.setMessage("Select download folder");
+				dialog.setFilterPath(destinationPathText.getText());
+				final String path = dialog.open();
+				if (path == null) {
+					return;
+				}
+				destinationPathText.setText(path);
+			}
+		
+		});
+		
+		destinationPathText.addModifyListener(new ModifyListener() {
+			
+			@Override
+			public void modifyText(ModifyEvent e) {
+				validate();
+			}
+		});
+		
+		deleteOnExit = new Button(pathComposite, SWT.CHECK);
+		gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+		gd.horizontalSpan=3;
+		deleteOnExit.setLayoutData(gd);
+		deleteOnExit.setText("Delete archive after installing");
+		
+		delete = dialogSettings.get(DELETE_ON_EXIT);
+		if (delete == null) {
+			delete = "true";
+		}
+		deleteOnExit.setSelection(new Boolean(delete));
+		deleteOnExit.addSelectionListener(new SelectionAdapter() {
+			
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				delete = new Boolean(deleteOnExit.getSelection()).toString();
+			}
+			
+		});
+		
+		return area;
+	}
+
+	private String getDefaultPath() {
+		String defaultPath = dialogSettings.get(DEFAULT_DIALOG_PATH);
+		if (defaultPath == null || defaultPath.isEmpty()) {
+			defaultPath=System.getProperty(USER_HOME);
+		}
+		return defaultPath;
+	}
+
+	private void showDecorations() {
+		String path = pathText.getText();
+		String destination = destinationPathText.getText();
+		decPathError.hide();
+		decPathReq.hide();
+		destinationPathError.hide();
+		destinationPathReq.hide();
+		if (path.isEmpty()) {
+			decPathReq.show();
+		}
+		if (destination.isEmpty()) {
+			destinationPathReq.show();
+		}
+		boolean pathExists = checkPath(path, decPathError);
+		boolean destExists = checkPath(destination, destinationPathError);
+		getButton(IDialogConstants.OK_ID).setEnabled(pathExists
+			&& destExists
+			&& !path.isEmpty() && !destination.isEmpty());
+		decPathError.setShowHover(true);
+	}
+
+	private boolean checkPath(String path, ControlDecoration dec) {
+		if (path.isEmpty()) {
+			return true;
+		}
+		try {
+			File file = File.createTempFile("temp", "txt", new File(path));
+			file.deleteOnExit();
+			file.delete();
+		} catch (IOException e) {
+			dec.show();
+			return false;
+		}
+		return true;
+	}
+
+	protected ControlDecoration addDecoration(Control control, String id, String description) {
+		final ControlDecoration decPath = new ControlDecoration(control, SWT.TOP
+				| SWT.LEFT);
+		FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
+		FieldDecoration fd = registry.getFieldDecoration(id);
+		decPath.setImage(fd.getImage());
+		fd.setDescription(description);
+	
+		decPath.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(
+				id).getImage());
+
+		decPath.setShowOnlyOnFocus(false);
+		decPath.setShowHover(true);
+		decPath.setDescriptionText(description);
+		return decPath;
+	}
+
+	protected void validate() {
+		getButton(IDialogConstants.OK_ID).setEnabled(true);
+		if (pathText.getText().isEmpty()) {
+			getButton(IDialogConstants.OK_ID).setEnabled(false);
+		}
+		if (destinationPathText.getText().isEmpty()) {
+			getButton(IDialogConstants.OK_ID).setEnabled(false);
+		}
+		showDecorations();
+	}
+
+	@Override
+	protected void okPressed() {
+		dialogSettings.put(DEFAULT_DESTINATION_PATH,
+				destinationPathText.getText());
+		dialogSettings.put(DEFAULT_DIALOG_PATH, pathText.getText());
+		dialogSettings.put(DELETE_ON_EXIT, delete);
+		String selectedDirectory = pathText.getText();
+		String destinationDirectory = destinationPathText.getText();
+		boolean del = deleteOnExit.getSelection();
+		super.okPressed();
+		downloadRuntime(selectedDirectory, destinationDirectory, del);
+	}
+
+	private void downloadRuntime(final String selectedDirectory,
+			final String destinationDirectory, final boolean deleteOnExit) {		
+		Job downloadJob = new Job("Download '" + downloadRuntime.getName()) {
+
+			@Override
+			public IStatus run(IProgressMonitor monitor) {
+				monitor.beginTask("Download '" + downloadRuntime.getName() + "' ...", 100);
+				downloadAndInstall(selectedDirectory,
+						destinationDirectory, deleteOnExit, monitor);
+				return Status.OK_STATUS;
+			}
+			
+		};
+		downloadJob.setUser(false);
+		downloadJob.schedule();
+		IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
+		progressService.showInDialog(getActiveShell(), downloadJob);
+	}
+	
+	private IStatus downloadAndInstall(String selectedDirectory, String destinationDirectory, boolean deleteOnExit, IProgressMonitor monitor) {
+		FileInputStream in = null;
+		OutputStream out = null;
+		File file = null;
+		try {
+			URL url = new URL(downloadRuntime.getUrl());
+			String name = url.getPath();
+			int slashIdx = name.lastIndexOf('/');
+			if (slashIdx >= 0)
+				name = name.substring(slashIdx + 1);
+			
+			File destination = new File(destinationDirectory);
+			destination.mkdirs();
+			file = new File (destination, name);
+			int i = 1;
+			boolean download = true;
+			long urlModified = 0;
+			if (deleteOnExit) {
+				while (file.exists()) {
+					file = new File(destination, name + "(" + i++ + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+				}
+			} else {
+				long cacheModified = file.lastModified();
+				try {
+					urlModified = ECFTransport.getInstance()
+							.getLastModified(url);
+					download = cacheModified <= 0 || cacheModified != urlModified;
+				} catch (CoreException e) {
+					// ignore
+				}
+			}
+			if (deleteOnExit) {
+				file.deleteOnExit();
+			}
+			IStatus result = null;
+			if (download) {
+				out = new BufferedOutputStream(new FileOutputStream(file));
+				result = ECFTransport.getInstance().download(
+						file.getName(), url.toExternalForm(), out, monitor);
+				out.flush();
+				out.close();
+				if (urlModified > 0) {
+					file.setLastModified(urlModified);
+				}
+			}
+			if (monitor.isCanceled()) {
+				file.deleteOnExit();
+				file.delete();
+				return Status.CANCEL_STATUS;
+			}
+			File directory = new File(selectedDirectory);
+			directory.mkdirs();
+			if (!directory.isDirectory()) {
+				final String message = "The '" + directory + "' is not a directory.";
+				if (result != null) {
+					RuntimeUIActivator.getDefault().getLog().log(result);
+				} else {
+					RuntimeUIActivator.getDefault().getLog().log(result);
+				}
+				Display.getDefault().syncExec(new Runnable() {
+
+					@Override
+					public void run() {
+						MessageDialog.openError(getActiveShell(), "Error", message);
+					}
+					
+				});
+				file.deleteOnExit();
+				file.delete();
+				return Status.CANCEL_STATUS;
+			}
+			new UnzipOperation(file).execute(directory);
+			if (result != null && !result.isOK()) {
+				RuntimeUIActivator.getDefault().getLog().log(result);
+				final String message = getMessage(result);
+				Display.getDefault().syncExec(new Runnable() {
+
+					@Override
+					public void run() {
+						MessageDialog.openError(getActiveShell(), "Error", message);
+					}
+					
+				});
+				file.deleteOnExit();
+				file.delete();
+				return Status.CANCEL_STATUS;
+			}
+			String root = getRoot(file, monitor);
+			if (monitor.isCanceled()) {
+				return Status.CANCEL_STATUS;
+			}
+			if (root != null) {
+				File rootFile = new File(selectedDirectory, root);
+				if (rootFile != null && rootFile.exists()) {
+					selectedDirectory = rootFile.getAbsolutePath();
+				}
+			}
+			createRuntimes(selectedDirectory, monitor);
+		} catch (IOException e) {
+			RuntimeUIActivator.log(e);
+			if (file != null && file.exists()) {
+				file.deleteOnExit();
+				file.delete();
+			}
+			final String message = e.getMessage();
+			Display.getDefault().syncExec(new Runnable() {
+
+				@Override
+				public void run() {
+					MessageDialog.openError(getActiveShell(), "Error", message);
+				}
+				
+			});
+		} finally {
+			if (in != null) {
+				try {
+					in.close();
+				} catch (IOException e) {
+					// ignore
+				}
+			}
+			if (out != null) {
+				try {
+					out.close();
+				} catch (IOException e) {
+					// ignore
+				}
+			}
+		}
+		return Status.OK_STATUS;
+	}
+
+	private String getMessage(IStatus result) {
+		String message;
+		if (result.getException() != null) {
+			message = result.getException().getMessage();
+		} else {
+			message = result.getMessage();
+		}
+		return message;
+	}
+	
+	private String getRoot(File file, IProgressMonitor monitor) {
+		ZipFile zipFile = null;
+		String root = null;
+		try {
+			zipFile = new ZipFile(file);
+			Enumeration<? extends ZipEntry> entries = zipFile.entries();
+			while (entries.hasMoreElements()) {
+				if (monitor.isCanceled()) {
+					return null;
+				}
+				ZipEntry entry = (ZipEntry) entries.nextElement();
+				String entryName = entry.getName();
+				if (entryName == null || entryName.isEmpty() 
+						|| entryName.startsWith(SEPARATOR) || entryName.indexOf(SEPARATOR) == -1) {
+					return null;
+				}
+				String directory = entryName.substring(0, entryName.indexOf(SEPARATOR));
+				if (root == null) {
+					root = directory;
+					continue;
+				}
+				if (!directory.equals(root)) {
+					return null;
+				}
+			}
+		} catch (IOException e) {
+			RuntimeUIActivator.log(e);
+			return null;
+		} finally {
+			if (zipFile != null) {
+				try {
+					zipFile.close();
+				} catch (IOException e) {
+					// ignore
+				}
+			}
+		}
+		return root;
+	}
+
+	private Shell getActiveShell() {
+		Display display = Display.getDefault();
+		if (display != null) {
+			return PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
+		}
+		return null;
+	}
+
+	private static void createRuntimes(String directory,
+			IProgressMonitor monitor) {
+		JBossRuntimeLocator locator = new JBossRuntimeLocator();
+		final RuntimePath runtimePath = new RuntimePath(directory);
+		List<RuntimeDefinition> serverDefinitions = locator.searchForRuntimes(
+				runtimePath.getPath(), monitor);
+		runtimePath.getRuntimeDefinitions().clear();
+		for (RuntimeDefinition serverDefinition : serverDefinitions) {
+			serverDefinition.setRuntimePath(runtimePath);
+		}
+		runtimePath.getRuntimeDefinitions().addAll(serverDefinitions);
+		RuntimeUIActivator.getDefault().getRuntimePaths().add(runtimePath);
+		RuntimeUIActivator.getDefault().saveRuntimePaths();
+		if (serverDefinitions.size() == 0) {
+			Display.getDefault().asyncExec(new Runnable() {
+
+				@Override
+				public void run() {
+					MessageDialog.openError(Display.getDefault()
+							.getActiveShell(), "Error", "No runtime/server found...");
+				}
+			});
+		}
+		if (serverDefinitions.size() > 1) {
+			Display.getDefault().asyncExec(new Runnable() {
+				
+				@Override
+				public void run() {
+					RuntimeUIActivator.refreshRuntimes(Display.getDefault()
+							.getActiveShell(), RuntimeUIActivator.getDefault().getRuntimePaths(), null, false, 7);
+				}
+			});
+			
+		} else {
+			Set<IRuntimeDetector> detectors = RuntimeCoreActivator.getDefault()
+					.getRuntimeDetectors();
+			for (IRuntimeDetector detector : detectors) {
+				if (detector.isEnabled()) {
+					detector.initializeRuntimes(serverDefinitions);
+				}
+			}
+		}
+	}
+
+	@Override
+	protected void createButtonsForButtonBar(Composite parent) {
+		super.createButtonsForButtonBar(parent);
+		showDecorations();
+	}
+
+}

Copied: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeViewerDialog.java (from rev 43403, trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeViewerDialog.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeViewerDialog.java	                        (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeViewerDialog.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -0,0 +1,219 @@
+/*************************************************************************************
+ * Copyright (c) 2010-2011 Red Hat, Inc. 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.download;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+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.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+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.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.RuntimeExtensionManager;
+import org.jboss.tools.runtime.core.model.DownloadRuntime;
+import org.jboss.tools.runtime.ui.dialogs.AutoResizeTableLayout;
+
+/**
+ * @author snjeza
+ * 
+ */
+public class DownloadRuntimeViewerDialog extends Dialog {
+	
+	private TableViewer viewer;
+	private Map<String, DownloadRuntime> downloadRuntimes;
+
+	public DownloadRuntimeViewerDialog(Shell parentShell) {
+		super(parentShell);
+		setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
+				| SWT.RESIZE | getDefaultOrientation());
+		downloadRuntimes = RuntimeCoreActivator.getDefault().getDownloadRuntimes(); 
+	}
+
+	@Override
+	protected Control createDialogArea(Composite parent) {
+		getShell().setText("Runtimes");
+		Composite area = (Composite) super.createDialogArea(parent);
+		area.setLayout(new GridLayout());
+		Composite contents = new Composite(area, SWT.NONE);
+		GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+		contents.setLayoutData(gd);
+		contents.setLayout(new GridLayout(1, false));
+		applyDialogFont(contents);
+		initializeDialogUnits(area);
+
+		viewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL
+				| SWT.V_SCROLL | SWT.BORDER);
+		gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+		gd.heightHint = 400;
+		gd.widthHint = 700;
+		viewer.getTable().setLayoutData(gd);
+		
+		Table table = viewer.getTable();
+		table.setHeaderVisible(true);
+		table.setLinesVisible(true);
+		table.setFont(parent.getFont());
+		
+		viewer.setContentProvider(new DownloadRuntimesContentProvider());
+		
+		//String[] columnHeaders = {"Name", "ID", "Version", "URL"};
+		String[] columnHeaders = {"Name", "ID", "Version"};
+		for (int i = 0; i < columnHeaders.length; i++) {
+			TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+			column.setLabelProvider(new DownloadRuntimesLabelProvider(i));
+			column.getColumn().setText(columnHeaders[i]);
+			column.getColumn().setResizable(true);
+			column.getColumn().setMoveable(true);
+		}
+		
+		ColumnLayoutData[] runtimePathsLayouts= {
+				new ColumnWeightData(250,250),
+				new ColumnWeightData(200,200),
+				new ColumnWeightData(150,150),
+				
+			};
+		
+		TableLayout layout = new AutoResizeTableLayout(table);
+		for (int i = 0; i < runtimePathsLayouts.length; i++) {
+			layout.addColumnData(runtimePathsLayouts[i]);
+		}
+		
+		viewer.setInput(downloadRuntimes);
+		if (downloadRuntimes.values().size() > 0) {
+			viewer.getTable().select(0);
+		}
+		viewer.getTable().setLayout(layout);
+		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+			
+			@Override
+			public void selectionChanged(SelectionChangedEvent event) {
+				validate();
+			}
+		});
+		return area;
+	}
+
+	class DownloadRuntimesContentProvider implements IStructuredContentProvider {
+
+		@Override
+		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+			
+		}
+
+		@Override
+		public Object[] getElements(Object inputElement) {
+			DownloadRuntime[] runtimes = downloadRuntimes.values().toArray(new DownloadRuntime[0]);
+			Arrays.sort(runtimes, new Comparator<DownloadRuntime>() {
+				
+				@Override
+				public int compare(DownloadRuntime o1, DownloadRuntime o2) {
+					if (o1 == null && o2 == null) {
+						return 0;
+					}
+					if (o1 == null) {
+						return 1;
+					}
+					if (o2 == null) {
+						return -1;
+					}
+					String s1 = o1.getName();
+					String s2 = o2.getName();
+					if (s1 == null && s2 == null) {
+						return 0;
+					}
+					if (s1 == null) {
+						return 1;
+					}
+					if (s2 == null) {
+						return -1;
+					}
+					return s1.compareTo(s2);
+				}
+			});
+			return runtimes;
+		}
+		
+		@Override
+		public void dispose() {
+			
+		}
+	}
+	
+	class DownloadRuntimesLabelProvider extends ColumnLabelProvider {
+
+		private int columnIndex;
+
+		public DownloadRuntimesLabelProvider(int i) {
+			this.columnIndex = i;
+		}
+
+		public String getText(Object element) {
+			if (element instanceof DownloadRuntime) {
+				DownloadRuntime downloadRuntime = (DownloadRuntime) element;
+				switch (columnIndex) {
+				case 0:
+					return downloadRuntime.getName();
+				case 1:
+					return downloadRuntime.getId();
+				case 2:
+					return downloadRuntime.getVersion();
+				case 3:
+					return downloadRuntime.getUrl();
+				}
+			}
+			return null;
+		}
+	}
+
+	@Override
+	protected void okPressed() {
+		ISelection selection = viewer.getSelection();
+		if (selection instanceof IStructuredSelection) {
+			IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+			Object object = structuredSelection.getFirstElement();
+			if (object instanceof DownloadRuntime) {
+				DownloadRuntime downloadRuntime = (DownloadRuntime) object;
+				DownloadRuntimeDialog dialog = new DownloadRuntimeDialog(getShell(), downloadRuntime);
+				dialog.open();
+			}
+		}
+		super.okPressed();
+	}
+
+	@Override
+	protected void createButtonsForButtonBar(Composite parent) {
+		super.createButtonsForButtonBar(parent);
+		validate();
+	}
+
+	protected void validate() {
+		getButton(IDialogConstants.OK_ID).setEnabled(viewer.getSelection() != null);
+	}
+	
+}

Copied: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimes.java (from rev 43403, trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/DownloadRuntimes.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimes.java	                        (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimes.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -0,0 +1,19 @@
+package org.jboss.tools.runtime.ui.download;
+
+import java.util.HashMap;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.runtime.ui.IDownloadRuntimes;
+
+public class DownloadRuntimes implements IDownloadRuntimes {
+	public static final String SHELL = "download.runtimes.shell";
+	@Override
+	public void execute(HashMap<String, Object> map) {
+		Object shell = map.get(SHELL);
+		Shell shell2 = shell == null ? Display.getDefault().getActiveShell() : ((Shell)shell);
+		DownloadRuntimeViewerDialog dialog = new DownloadRuntimeViewerDialog(shell2);
+		dialog.open();
+	}
+
+}

Modified: 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	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java	2012-09-05 15:22:34 UTC (rev 43419)
@@ -11,6 +11,7 @@
 package org.jboss.tools.runtime.ui.preferences;
 
 import java.io.File;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -80,6 +81,7 @@
 import org.jboss.tools.runtime.ui.dialogs.AutoResizeTableLayout;
 import org.jboss.tools.runtime.ui.dialogs.EditRuntimePathDialog;
 import org.jboss.tools.runtime.ui.dialogs.RuntimePathEditingSupport;
+import org.jboss.tools.runtime.ui.download.DownloadRuntimes;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 
@@ -442,7 +444,9 @@
 		downloadButton.addSelectionListener(new SelectionListener(){
 		
 			public void widgetSelected(SelectionEvent e) {
-				downloader.execute(getShell());
+				HashMap<String, Object> data = new HashMap<String, Object>();
+				data.put(DownloadRuntimes.SHELL, getShell());
+				downloader.execute(data);
 			}
 		
 			public void widgetDefaultSelected(SelectionEvent e) {
@@ -469,14 +473,7 @@
 	}
 
 	private IDownloadRuntimes getDownloader() {
-		Bundle bundle = Platform.getBundle("org.jboss.tools.project.examples");
-		if (bundle != null) {
-			ServiceReference<IDownloadRuntimes> reference = bundle.getBundleContext().getServiceReference(IDownloadRuntimes.class);
-			if (reference != null) {
-				return bundle.getBundleContext().getService(reference);
-			}
-		} 
-		return null;
+		return new DownloadRuntimes();
 	}
 	
 	public void init(IWorkbench workbench) {

Modified: trunk/seam/plugins/org.jboss.tools.runtime.seam.detector/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.runtime.seam.detector/plugin.xml	2012-09-05 15:04:29 UTC (rev 43418)
+++ trunk/seam/plugins/org.jboss.tools.runtime.seam.detector/plugin.xml	2012-09-05 15:22:34 UTC (rev 43419)
@@ -11,4 +11,22 @@
        		preferenceId="org.jboss.tools.common.model.ui.seam"
        		priority="200"/>
 	</extension>
+	
+	<extension
+         point="org.jboss.tools.runtime.core.downloadruntimes">
+      <runtime
+            id="org.jboss.tools.runtime.core.seam.222" 
+            name="JBoss Seam 2.2.2.Final"
+            version="2.2.2.Final"
+            size="113.2MB"
+            url="http://sourceforge.net/projects/jboss/files/JBoss%20Seam/2.2.2.Final/jboss-seam-2.2.2.Final.zip?use_mirror=autoselect"
+            disclaimer="true"/>
+      <runtime
+            id="org.jboss.tools.runtime.core.seam.202" 
+            name="JBoss Seam 2.0.2.SP1"
+            version="2.0.2.SP1"
+            size="92.3MB"
+            url="http://sourceforge.net/projects/jboss/files/JBoss%20Seam/2.0.2.SP1/jboss-seam-2.0.2.SP1.zip?use_mirror=autoselect"
+            disclaimer="true"/>
+   </extension>
 </plugin>



More information about the jbosstools-commits mailing list