Author: snjeza
Date: 2012-02-15 17:45:01 -0500 (Wed, 15 Feb 2012)
New Revision: 38786
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java
Removed:
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/model/DownloadRuntime.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/actions/DownloadRuntimeAction.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeDialog.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeViewerDialog.java
Modified:
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.ui/META-INF/MANIFEST.MF
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
Log:
JBIDE-10264 Wizard-ify the project examples
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml 2012-02-15 22:44:23 UTC
(rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml 2012-02-15 22:45:01 UTC
(rev 38786)
@@ -2,49 +2,4 @@
<?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"/>
-
- <extension
- point="org.jboss.tools.runtime.core.downloadruntimes">
- <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/jbos...
- <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/jbos...
- <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....
- <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....
-
- <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...
- <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.G...
-
-
- </extension>
-
</plugin>
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd 2012-02-15
22:44:23 UTC (rev 38785)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd 2012-02-15
22:45:01 UTC (rev 38786)
@@ -1,138 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.jboss.tools.central"
xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.jboss.tools.central"
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>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 3.0.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- <extension
- point="org.jboss.tools.central.downloadruntimes">
-
-</extension>
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- JBoss by Red Hat
- </documentation>
- </annotation>
-
-</schema>
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-02-15
22:44:23 UTC (rev 38785)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java 2012-02-15
22:45:01 UTC (rev 38786)
@@ -11,9 +11,7 @@
package org.jboss.tools.runtime.core;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
@@ -29,7 +27,6 @@
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.jboss.tools.runtime.core.model.DownloadRuntime;
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
import org.jboss.tools.runtime.core.model.InvalidRuntimeDetector;
import org.osgi.framework.BundleContext;
@@ -49,8 +46,6 @@
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.core.downloadruntimes";
-
private static final String NAME = "name";
private static final String PREFERENCE_ID = "preferenceId";
@@ -74,12 +69,6 @@
private static IEclipsePreferences prefs;
- private static final String VERSION = "version"; //$NON-NLS-1$
- private static final String URL = "url"; //$NON-NLS-1$
-
-
- private Map<String, DownloadRuntime> downloadRuntimes;
-
/**
* The constructor
*/
@@ -237,28 +226,4 @@
return esbDetector;
}
- 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);
- DownloadRuntime downloadRuntime = new DownloadRuntime(id, name, version, url);
- downloadRuntimes.put(id, downloadRuntime);
- }
- }
- }
- return downloadRuntimes;
- }
}
Deleted:
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/model/DownloadRuntime.java 2012-02-15
22:44:23 UTC (rev 38785)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java 2012-02-15
22:45:01 UTC (rev 38786)
@@ -1,88 +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.runtime.core.model;
-
-/**
- *
- * @author snjeza
- *
- */
-public class DownloadRuntime {
- private String name;
- private String id;
- private String version;
- private String url;
-
- 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 + "]";
- }
-
-}
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-02-15
22:44:23 UTC (rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF 2012-02-15
22:45:01 UTC (rev 38786)
@@ -8,13 +8,11 @@
org.eclipse.core.runtime,
org.jboss.tools.runtime.core,
org.eclipse.core.resources,
- org.jboss.tools.project.examples,
org.eclipse.ui.navigator;bundle-version="3.5.100"
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.actions,
org.jboss.tools.runtime.ui.dialogs,
org.jboss.tools.runtime.ui.preferences
Added:
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
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java 2012-02-15
22:45:01 UTC (rev 38786)
@@ -0,0 +1,8 @@
+package org.jboss.tools.runtime.ui;
+
+import org.eclipse.swt.widgets.Shell;
+
+public interface IDownloadRuntimes {
+
+ void execute(Shell shell);
+}
Deleted:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/actions/DownloadRuntimeAction.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/actions/DownloadRuntimeAction.java 2012-02-15
22:44:23 UTC (rev 38785)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/actions/DownloadRuntimeAction.java 2012-02-15
22:45:01 UTC (rev 38786)
@@ -1,70 +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.runtime.ui.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.runtime.core.RuntimeCoreActivator;
-import org.jboss.tools.runtime.core.model.DownloadRuntime;
-import org.jboss.tools.runtime.ui.dialogs.DownloadRuntimeDialog;
-
-/**
- *
- * @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 =
RuntimeCoreActivator.getDefault().getDownloadRuntimes().get(runtimeId);
- DownloadRuntimeDialog dialog = new DownloadRuntimeDialog(getShell(), runtime);
- dialog.open();
- }
-
- private Shell getShell() {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-
- }
-
-}
Deleted:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeDialog.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeDialog.java 2012-02-15
22:44:23 UTC (rev 38785)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeDialog.java 2012-02-15
22:45:01 UTC (rev 38786)
@@ -1,442 +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.runtime.ui.dialogs;
-
-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.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.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.jface.operation.IRunnableWithProgress;
-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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.project.examples.ProjectExamplesActivator;
-import org.jboss.tools.project.examples.filetransfer.ECFExamplesTransport;
-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.RuntimePath;
-import org.jboss.tools.runtime.core.model.RuntimeDefinition;
-import org.jboss.tools.runtime.ui.RuntimeUIActivator;
-
-/**
- * @author snjeza
- *
- */
-public class DownloadRuntimeDialog extends Dialog {
-
- 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";
- private static final String JAVA_IO_TMPDIR = "java.io.tmpdir";
- private static final String USER_HOME = "user.home";
- private static final String DEFAULT_DIALOG_PATH = "defaultDialogPath";
- private static final String DEFAULT_DESTINATION_PATH =
"defaultDestinationPath";
- 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);
- //gd.heightHint = 200;
- gd.widthHint = 600;
- contents.setLayoutData(gd);
- contents.setLayout(new GridLayout(1, false));
- applyDialogFont(contents);
- initializeDialogUnits(area);
-
- Composite pathComposite = new Composite(contents, SWT.NONE);
- gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- pathComposite.setLayoutData(gd);
- pathComposite.setLayout(new GridLayout(3, false));
-
-
- Label pathLabel = new Label(pathComposite, SWT.NONE);
- pathLabel.setText("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);
- 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) {
- final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
- dialog.setBlockOnOpen(false);
- dialog.setCancelable(true);
- dialog.open();
- final IProgressMonitor monitor = dialog.getProgressMonitor();
- monitor.beginTask("Download '" + downloadRuntime.getName() + "'
...", 100);
-
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- downloadAndInstall(selectedDirectory,
- destinationDirectory, deleteOnExit, monitor);
- }
- };
- try {
- dialog.run(true, true, runnable);
- } catch (Exception e) {
- RuntimeCoreActivator.log(e);
- MessageDialog.openError(getActiveShell(), "Error", e.getMessage());
- }
- }
-
- 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;
- while (file.exists()) {
- file = new File(destination, name + "(" + i++ + ")");
- }
-
- if (deleteOnExit) {
- file.deleteOnExit();
- }
- out = new BufferedOutputStream(
- new FileOutputStream(file));
-
- IStatus result = ECFExamplesTransport.getInstance().download(file.getName(),
- url.toExternalForm(), out, monitor);
- out.flush();
- out.close();
- if (monitor.isCanceled()) {
- file.deleteOnExit();
- file.delete();
- return Status.CANCEL_STATUS;
- }
- File directory = new File(selectedDirectory);
- directory.mkdirs();
- if (!directory.isDirectory()) {
- RuntimeCoreActivator.getDefault().getLog().log(result);
- MessageDialog.openError(getActiveShell(), "Error", "The '" +
directory + "' is not a directory.");
- file.deleteOnExit();
- file.delete();
- return Status.CANCEL_STATUS;
- }
- ProjectExamplesActivator.extractZipFile(file, directory, monitor);
- if (!result.isOK()) {
- RuntimeCoreActivator.getDefault().getLog().log(result);
- String message;
- if (result.getException() != null) {
- message = result.getException().getMessage();
- } else {
- message = result.getMessage();
- }
- MessageDialog.openError(getActiveShell(), "Error", message);
- file.deleteOnExit();
- file.delete();
- return Status.CANCEL_STATUS;
- }
- createRuntimes(selectedDirectory, monitor);
- } catch (IOException e) {
- RuntimeCoreActivator.log(e);
- if (file != null && file.exists()) {
- file.deleteOnExit();
- file.delete();
- }
- MessageDialog.openError(getActiveShell(), "Error", e.getMessage());
- } 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 Shell getActiveShell() {
- Display display = Display.getDefault();
- if (display != null) {
- return display.getActiveShell();
- }
- return null;
- }
-
- private static void createRuntimes(String directory, IProgressMonitor monitor) {
- JBossRuntimeLocator locator = new JBossRuntimeLocator();
- Set<RuntimePath> runtimePaths = RuntimeUIActivator.getDefault()
- .getRuntimePaths();
- RuntimePath newPath = new RuntimePath(directory);
- runtimePaths.add(newPath);
- for (RuntimePath runtimePath : runtimePaths) {
- List<RuntimeDefinition> serverDefinitions = locator
- .searchForRuntimes(runtimePath.getPath(),
- monitor);
- runtimePath.getServerDefinitions().clear();
- for (RuntimeDefinition serverDefinition : serverDefinitions) {
- serverDefinition.setRuntimePath(runtimePath);
- }
- runtimePath.getServerDefinitions().addAll(serverDefinitions);
- RuntimeUIActivator.getDefault().getRuntimePaths().add(runtimePath);
- RuntimeUIActivator.getDefault().saveRuntimePaths();
- }
- List<RuntimeDefinition> serverDefinitions = RuntimeUIActivator
- .getDefault().getServerDefinitions();
- Set<IRuntimeDetector> detectors = RuntimeCoreActivator
- .getRuntimeDetectors();
- for (IRuntimeDetector detector : detectors) {
- if (detector.isEnabled()) {
- detector.initializeRuntimes(serverDefinitions);
- }
- }
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- showDecorations();
- }
-
-}
Deleted:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeViewerDialog.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeViewerDialog.java 2012-02-15
22:44:23 UTC (rev 38785)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeViewerDialog.java 2012-02-15
22:45:01 UTC (rev 38786)
@@ -1,188 +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.runtime.ui.dialogs;
-
-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.model.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 = 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) {
- return downloadRuntimes.values().toArray(new DownloadRuntime[0]);
- }
-
- @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);
- }
-
-}
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-02-15
22:44:23 UTC (rev 38785)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2012-02-15
22:45:01 UTC (rev 38786)
@@ -16,6 +16,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
@@ -71,12 +72,13 @@
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
import org.jboss.tools.runtime.core.model.RuntimePath;
+import org.jboss.tools.runtime.ui.IDownloadRuntimes;
import org.jboss.tools.runtime.ui.RuntimeUIActivator;
import org.jboss.tools.runtime.ui.dialogs.AutoResizeTableLayout;
-import org.jboss.tools.runtime.ui.dialogs.DownloadRuntimeDialog;
-import org.jboss.tools.runtime.ui.dialogs.DownloadRuntimeViewerDialog;
import org.jboss.tools.runtime.ui.dialogs.EditRuntimePathDialog;
import org.jboss.tools.runtime.ui.dialogs.RuntimePathEditingSupport;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
/**
* @author snjeza
@@ -411,11 +413,12 @@
downloadButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
downloadButton.setText("Download...");
+ final IDownloadRuntimes downloader = getDownloader();
+ downloadButton.setEnabled(downloader != null);
downloadButton.addSelectionListener(new SelectionListener(){
public void widgetSelected(SelectionEvent e) {
- DownloadRuntimeViewerDialog dialog = new DownloadRuntimeViewerDialog(getShell());
- dialog.open();
+ downloader.execute(getShell());
}
public void widgetDefaultSelected(SelectionEvent e) {
@@ -441,6 +444,17 @@
});
}
+ 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;
+ }
+
public void init(IWorkbench workbench) {
runtimePaths = RuntimeUIActivator.getDefault().getRuntimePaths();
runtimeDetectors = RuntimeUIActivator.getDefault().getRuntimeDetectors();