[jbosstools-commits] JBoss Tools SVN: r43583 - in trunk: as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards and 7 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Sep 11 06:20:57 EDT 2012
Author: rob.stryker at jboss.com
Date: 2012-09-11 06:20:57 -0400 (Tue, 11 Sep 2012)
New Revision: 43583
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
trunk/as/plugins/org.jboss.tools.runtime.as.detector/plugin.xml
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/internal/RuntimeExtensionManager.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.ui/META-INF/MANIFEST.MF
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/preferences/RuntimePreferencePage.java
Log:
JBIDE-12581 license for download runtimes. JBIDE-6116 allow for download of jboss-as runtimes
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2012-09-11 09:44:44 UTC (rev 43582)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2012-09-11 10:20:57 UTC (rev 43583)
@@ -51,6 +51,12 @@
public static String JBossRuntimeWizardFragment_DeleteConfigTitle;
public static String JBossRuntimeWizardFragment_MustSelectValidConfig;
public static String JBossRuntimeWizardFragment_OutputFolderExists;
+ public static String rwf_DownloadRuntime;
+ public static String rwf_InstallingRuntimeJob;
+ public static String rwf_DownloadAndInstallRuntimeWizard;
+ public static String rwf_DownloadingMayTakeLongTime;
+ public static String rwf_DownloadServerFileChooser;
+ public static String rwf_InstallingASTitle;
public static String rwf_CopyConfigLabel;
public static String rwf_DestinationLabel;
public static String rwf_JBossRuntime;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2012-09-11 09:44:44 UTC (rev 43582)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2012-09-11 10:20:57 UTC (rev 43583)
@@ -9,6 +9,12 @@
wf_JRELabel=JRE
wf_ExecEnvironmentLabel=Execution Environment
wf_ConfigLabel=Configuration
+rwf_DownloadRuntime=Download and install runtime...
+rwf_InstallingRuntimeJob=Downloading and Installing {0}
+rwf_DownloadAndInstallRuntimeWizard=Download and Install JBoss Runtime
+rwf_DownloadingMayTakeLongTime=The application server is being downloaded and unzipped into {0}. This may take a significant amount of time. You may create a new runtime in this wizard after the installation job is complete. This wizard will now close.
+rwf_DownloadServerFileChooser=Please select the folder to install the application server into.
+rwf_InstallingASTitle=Installing JBoss Application Server
rwf_CopyConfigLabel=Copy configuration "{0}" to a new destination from "{1}".
rwf_DestinationLabel=Destination
rwf_JBossRuntime=JBoss Runtime
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2012-09-11 09:44:44 UTC (rev 43582)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2012-09-11 10:20:57 UTC (rev 43583)
@@ -17,9 +17,14 @@
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.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jdt.launching.IVMInstall;
@@ -37,6 +42,8 @@
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
@@ -56,6 +63,7 @@
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.Shell;
@@ -66,16 +74,18 @@
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.TaskModel;
+import org.eclipse.wst.server.core.internal.IInstallableRuntime;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
+import org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment;
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
import org.jboss.ide.eclipse.as.core.server.internal.AbstractLocalJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.IConstants;
-import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.ide.eclipse.as.ui.IPreferenceKeys;
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
@@ -100,6 +110,7 @@
protected int jreComboIndex;
protected Button homeDirButton, jreButton;
protected Composite nameComposite, homeDirComposite, jreComposite;
+ protected Button downloadAndInstallButton;
protected String name, homeDir;
// Configuration stuff
@@ -334,6 +345,12 @@
homeDirButton = new Button(homeDirComposite, SWT.NONE);
homeDirButton.setText(Messages.browse);
+ downloadAndInstallButton = new Button(homeDirComposite, SWT.NONE);
+ downloadAndInstallButton.setText(Messages.rwf_DownloadRuntime);
+ downloadAndInstallButton.addSelectionListener(new DownloadAndInstallListener());
+ final IInstallableRuntime ir = ServerPlugin.findInstallableRuntime(getRuntimeType().getId());
+ downloadAndInstallButton.setEnabled(ir != null);
+
// Add listeners
homeDirText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
@@ -354,23 +371,82 @@
});
// Set Layout Data
- FormData labelData = new FormData();
- FormData textData = new FormData();
- FormData buttonData = new FormData();
+ homeDirLabel.setLayoutData(UIUtil.createFormData2(null,0,homeDirText,-5,0,5,null,0));
+ homeDirText.setLayoutData(UIUtil.createFormData2(homeDirLabel,5,null,0,0,5,homeDirButton,-5));
+ homeDirButton.setLayoutData(UIUtil.createFormData2(homeDirLabel,5,null,0,null,0,100,0));
+ downloadAndInstallButton.setLayoutData(UIUtil.createFormData2(0,0,homeDirButton,-5,null,0,100,-5));
+ }
- labelData.left = new FormAttachment(0, 0);
- homeDirLabel.setLayoutData(labelData);
-
- textData.left = new FormAttachment(0, 5);
- textData.right = new FormAttachment(homeDirButton, -5);
- textData.top = new FormAttachment(homeDirLabel, 5);
- homeDirText.setLayoutData(textData);
-
- buttonData.top = new FormAttachment(homeDirLabel, 5);
- buttonData.right = new FormAttachment(100, 0);
- homeDirButton.setLayoutData(buttonData);
+ protected class DownloadAndInstallListener extends SelectionAdapter {
+ public void widgetSelected(SelectionEvent se) {
+ downloadAndInstallButton.setEnabled(false);
+ String license = null;
+ final IInstallableRuntime ir = ServerPlugin.findInstallableRuntime(getRuntimeType().getId());
+
+ try {
+ license = ir.getLicense(new NullProgressMonitor());
+ } catch (CoreException e) {
+ }
+ TaskModel taskModel = new TaskModel();
+ taskModel.putObject(LicenseWizardFragment.LICENSE, license);
+ TaskWizard wizard2 = new TaskWizard(Messages.rwf_DownloadAndInstallRuntimeWizard, new WizardFragment() {
+ protected void createChildFragments(List list) {
+ list.add(new LicenseWizardFragment());
+ }
+ }, taskModel);
+
+ WizardDialog dialog2 = new WizardDialog(downloadAndInstallButton.getShell(), wizard2);
+ if (dialog2.open() == Window.CANCEL) {
+ downloadAndInstallButton.setEnabled(true);
+ return;
+ }
+ DirectoryDialog dialog = new DirectoryDialog(downloadAndInstallButton.getShell());
+ dialog.setMessage(Messages.rwf_DownloadServerFileChooser);
+ dialog.setFilterPath(homeDirText.getText());
+ String selectedDirectory = dialog.open();
+ if (selectedDirectory != null) {
+// ir.install(new Path(selectedDirectory));
+ final IPath installPath = new Path(selectedDirectory);
+ final Job installRuntimeJob = new Job(
+ NLS.bind(Messages.rwf_InstallingRuntimeJob, getRuntimeType().getName())) {
+ public boolean belongsTo(Object family) {
+ return ServerPlugin.PLUGIN_ID.equals(family);
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ ir.install(installPath, monitor);
+ } catch (CoreException ce) {
+ return ce.getStatus();
+ }
+
+ return Status.OK_STATUS;
+ }
+ };
+
+ homeDirText.setText(selectedDirectory);
+ JobChangeAdapter jobListener = new JobChangeAdapter() {
+ public void done(IJobChangeEvent event) {
+ installRuntimeJob.removeJobChangeListener(this);
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if( !downloadAndInstallButton.isDisposed())
+ downloadAndInstallButton.setEnabled(true);
+ }
+ });
+ }
+ };
+ installRuntimeJob.addJobChangeListener(jobListener);
+ installRuntimeJob.schedule();
+ handle.setMessage(Messages.rwf_DownloadingMayTakeLongTime, IMessageProvider.WARNING);
+ MessageDialog.openWarning(downloadAndInstallButton.getShell(), Messages.rwf_InstallingASTitle,
+ NLS.bind(Messages.rwf_DownloadingMayTakeLongTime, selectedDirectory));
+ ((TitleAreaDialog)((IWizardPage)handle).getWizard().getContainer()).close();
+ }
+ }
}
-
+
+
protected void createJREComposite(Composite main) {
// Create our composite
jreComposite = new Composite(main, SWT.NONE);
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-11 09:44:44 UTC (rev 43582)
+++ trunk/as/plugins/org.jboss.tools.runtime.as.detector/plugin.xml 2012-09-11 10:20:57 UTC (rev 43583)
@@ -16,17 +16,53 @@
<extension
point="org.jboss.tools.runtime.core.downloadruntimes">
<runtime
+ id="org.jboss.tools.runtime.core.as.328"
+ name="JBoss AS 3.2.8"
+ version="3.2.8"
+ size="100MB"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ url="http://repository.jboss.org/sourceforge/jboss-3.2.8.SP1.zip"
+ disclaimer="true"/>
+ <runtime
+ id="org.jboss.tools.runtime.core.as.405"
+ name="JBoss AS 4.0.5"
+ version="4.0.5"
+ size="100MB"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ url="http://repository.jboss.org/sourceforge/jboss-4.0.5.GA.zip"
+ disclaimer="true"/>
+ <runtime
id="org.jboss.tools.runtime.core.as.423"
name="JBoss AS 4.2.3"
version="4.2.3"
size="100MB"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
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.501"
+ name="JBoss AS 5.0.1"
+ version="5.0.1"
+ size="100MB"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ url="http://repository.jboss.org/sourceforge/jboss-5.0.1.GA.zip"
+ disclaimer="true"/>
+ <runtime
+ id="org.jboss.tools.runtime.core.as.510"
+ name="JBoss AS 5.1.0"
+ version="5.1.0"
+ size="100MB"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ url="http://repository.jboss.org/sourceforge/jboss-5.1.0.GA.zip"
+ disclaimer="true"/>
+
+ <runtime
id="org.jboss.tools.runtime.core.as.610"
name="JBoss AS 6.1.0"
version="6.1.0.Final"
size="183MB"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
url="http://download.jboss.org/jbossas/6.1/jboss-as-distribution-6.1.0.Final.zip?use_mirror=autoselect"
disclaimer="true"/>
<runtime
@@ -34,6 +70,7 @@
name="JBoss AS 7.0.1 Everything (NOT Java EE6 Certified)"
version="7.0.1.Final"
size="74MB"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
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
@@ -41,6 +78,7 @@
name="JBoss AS 7.0.2 Everything (NOT Java EE6 Certified)"
version="7.0.2.Final"
size="75MB"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
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
@@ -48,6 +86,7 @@
name="JBoss AS 7.1.1 Certified Java EE 6 Full Profile"
version="7.1.1.Final"
size="127MB"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
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
@@ -55,7 +94,55 @@
name="JBoss AS 7.1.0 Certified Java EE 6 Full Profile"
version="7.1.0.Final"
size="100MB"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
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>
+
+
+
+ <!-- Another set of hugely verbose and unnecessary xml for downloading remote jboss-as installations -->
+ <extension point="org.eclipse.wst.server.core.installableRuntimes">
+ <runtime
+ id="org.jboss.ide.eclipse.as.runtime.32"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ archiveUrl="http://repository.jboss.org/sourceforge/jboss-3.2.8.SP1.zip"
+ archivePath="jboss-3.2.8.SP1.zip"/>
+ <runtime
+ id="org.jboss.ide.eclipse.as.runtime.40"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ archiveUrl="http://repository.jboss.org/sourceforge/jboss-4.0.5.GA.zip"
+ archivePath="jboss-4.0.5.GA"/>
+ <runtime
+ id="org.jboss.ide.eclipse.as.runtime.42"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ archiveUrl="http://repository.jboss.org/sourceforge/jboss-4.2.3.GA.zip"
+ archivePath="jboss-4.2.3.GA"/>
+ <runtime
+ id="org.jboss.ide.eclipse.as.runtime.50"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ archiveUrl="http://repository.jboss.org/sourceforge/jboss-5.0.1.GA.zip"
+ archivePath="jboss-5.0.1.GA"/>
+ <runtime
+ id="org.jboss.ide.eclipse.as.runtime.51"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ archiveUrl="http://repository.jboss.org/sourceforge/jboss-5.1.0.GA.zip"
+ archivePath="jboss-5.1.0.GA"/>
+ <runtime
+ id="org.jboss.ide.eclipse.as.runtime.60"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ archiveUrl="http://download.jboss.org/jbossas/6.1/jboss-as-distribution-6.1.0.Final.zip"
+ archivePath="jboss-6.1.0.Final"/>
+ <runtime
+ id="org.jboss.ide.eclipse.as.runtime.70"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ archiveUrl="http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-web-7.0.2.Final.zip"
+ archivePath="jboss-as-7.0.2.Final"/>
+ <runtime
+ id="org.jboss.ide.eclipse.as.runtime.71"
+ licenseUrl="http://www.gnu.org/licenses/lgpl-2.1.txt"
+ archiveUrl="http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip"
+ archivePath="jboss-as-7.1.1.Final"/>
+ </extension>
+
</plugin>
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd 2012-09-11 09:44:44 UTC (rev 43582)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd 2012-09-11 10:20:57 UTC (rev 43583)
@@ -1,134 +1,141 @@
-<?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>
+<?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>
+ <attribute name="licenseURL" type="string">
+ <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>
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeExtensionManager.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeExtensionManager.java 2012-09-11 09:44:44 UTC (rev 43582)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeExtensionManager.java 2012-09-11 10:20:57 UTC (rev 43583)
@@ -50,6 +50,7 @@
private static final String URL = "url"; //$NON-NLS-1$
private static final String DISCLAIMER = "disclaimer"; //$NON-NLS-1$
+ private static final String LICENSE_URL = "licenseUrl";//$NON-NLS-1$
private static final String VERSION = "version";
private static final String NAME = "name";
private static final String PREFERENCE_ID = "preferenceId";
@@ -257,7 +258,11 @@
String version = configurationElement.getAttribute(VERSION);
String url = configurationElement.getAttribute(URL);
String disclaimer = configurationElement.getAttribute(DISCLAIMER);
+ String licenseURL = configurationElement.getAttribute(LICENSE_URL);
DownloadRuntime downloadRuntime = new DownloadRuntime(id, name, version, url);
+ if( licenseURL != null ) {
+ downloadRuntime.setLicenseURL(licenseURL);
+ }
if (Boolean.FALSE.toString().equals(disclaimer)) {
downloadRuntime.setDisclaimer(false);
}
Modified: 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-09-11 09:44:44 UTC (rev 43582)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java 2012-09-11 10:20:57 UTC (rev 43583)
@@ -10,16 +10,32 @@
************************************************************************************/
package org.jboss.tools.runtime.core.model;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+
+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.SubMonitor;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+
/**
*
* @author snjeza
*
*/
public class DownloadRuntime {
+ private byte[] BUFFER = null;
private String name;
private String id;
private String version;
private String url;
+ private String licenseURL;
private boolean disclaimer = true;
public DownloadRuntime(String id, String name, String version, String url) {
@@ -93,5 +109,49 @@
public void setDisclaimer(boolean disclaimer) {
this.disclaimer = disclaimer;
}
+
+ public void setLicenseURL(String url) {
+ this.licenseURL = url;
+ }
+ /*
+ * @see IInstallableRuntime#getLicense(IProgressMonitor)
+ */
+ public String getLicense(IProgressMonitor monitor) throws CoreException {
+ URL url = null;
+ ByteArrayOutputStream out = null;
+ try {
+ if (licenseURL == null)
+ return null;
+
+ url = new URL(licenseURL);
+ InputStream in = url.openStream();
+ out = new ByteArrayOutputStream();
+ copyWithSize(in, out, null, 0);
+ return new String(out.toByteArray());
+ } catch (Exception e) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ RuntimeCoreActivator.PLUGIN_ID, 0,
+ NLS.bind("Unable to fetch license for {0}", e.getLocalizedMessage()), e));
+ } finally {
+ try {
+ if (out != null)
+ out.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+
+ private void copyWithSize(InputStream in, OutputStream out, IProgressMonitor monitor, int size) throws IOException {
+ if (BUFFER == null)
+ BUFFER = new byte[8192];
+ SubMonitor progress = SubMonitor.convert(monitor, size);
+ int r = in.read(BUFFER);
+ while (r >= 0) {
+ out.write(BUFFER, 0, r);
+ progress.worked(r);
+ r = in.read(BUFFER);
+ }
+ }
}
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-11 09:44:44 UTC (rev 43582)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF 2012-09-11 10:20:57 UTC (rev 43583)
@@ -14,7 +14,9 @@
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"
+ org.jboss.tools.common.core;bundle-version="3.4.0",
+ org.eclipse.wst.server.ui;bundle-version="1.4.0",
+ org.eclipse.wst.server.core;bundle-version="1.4.0"
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Modified: 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/DownloadRuntimeViewerDialog.java 2012-09-11 09:44:44 UTC (rev 43582)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeViewerDialog.java 2012-09-11 10:20:57 UTC (rev 43583)
@@ -12,8 +12,11 @@
import java.util.Arrays;
import java.util.Comparator;
+import java.util.List;
import java.util.Map;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ColumnLabelProvider;
@@ -28,6 +31,8 @@
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -35,6 +40,10 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
+import org.eclipse.wst.server.core.TaskModel;
+import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
+import org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
import org.jboss.tools.runtime.core.RuntimeCoreActivator;
import org.jboss.tools.runtime.core.model.DownloadRuntime;
import org.jboss.tools.runtime.ui.dialogs.AutoResizeTableLayout;
@@ -198,13 +207,41 @@
Object object = structuredSelection.getFirstElement();
if (object instanceof DownloadRuntime) {
DownloadRuntime downloadRuntime = (DownloadRuntime) object;
- DownloadRuntimeDialog dialog = new DownloadRuntimeDialog(getShell(), downloadRuntime);
- dialog.open();
+ if( licenseApproved(downloadRuntime)) {
+ DownloadRuntimeDialog dialog = new DownloadRuntimeDialog(getShell(), downloadRuntime);
+ dialog.open();
+ }
}
}
super.okPressed();
}
+
+ private boolean licenseApproved(DownloadRuntime downloadRuntime) {
+ String license = null;
+ try {
+ license = downloadRuntime.getLicense(new NullProgressMonitor());
+ System.out.println(license);
+ } catch(CoreException ce) {
+ ce.printStackTrace();
+ }
+ if( license != null ) {
+ TaskModel taskModel = new TaskModel();
+ taskModel.putObject(LicenseWizardFragment.LICENSE, license);
+ TaskWizard wizard2 = new TaskWizard("Download and Install Runtime", new WizardFragment() {
+ protected void createChildFragments(List list) {
+ list.add(new LicenseWizardFragment());
+ }
+ }, taskModel);
+
+ WizardDialog dialog2 = new WizardDialog(viewer.getTable().getShell(), wizard2);
+ if (dialog2.open() == Window.CANCEL) {
+ return false;
+ }
+ }
+ return true;
+ }
+
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
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-11 09:44:44 UTC (rev 43582)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2012-09-11 10:20:57 UTC (rev 43583)
@@ -345,17 +345,13 @@
final IDownloadRuntimes downloader = getDownloader();
downloadButton.setEnabled(downloader != null);
- downloadButton.addSelectionListener(new SelectionListener(){
+ downloadButton.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
HashMap<String, Object> data = new HashMap<String, Object>();
data.put(DownloadRuntimes.SHELL, getShell());
downloader.execute(data);
}
-
- public void widgetDefaultSelected(SelectionEvent e) {
-
- }
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
More information about the jbosstools-commits
mailing list