Author: snjeza
Date: 2012-02-15 17:40:09 -0500 (Wed, 15 Feb 2012)
New Revision: 38784
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/OSGI-INF/
trunk/examples/plugins/org.jboss.tools.project.examples/OSGI-INF/downloadRuntime.xml
trunk/examples/plugins/org.jboss.tools.project.examples/icons/jboss.png
trunk/examples/plugins/org.jboss.tools.project.examples/icons/seam16.png
trunk/examples/plugins/org.jboss.tools.project.examples/icons/software.png
trunk/examples/plugins/org.jboss.tools.project.examples/icons/wtp_server.gif
trunk/examples/plugins/org.jboss.tools.project.examples/schema/configurators.exsd
trunk/examples/plugins/org.jboss.tools.project.examples/schema/downloadruntimes.exsd
trunk/examples/plugins/org.jboss.tools.project.examples/schema/wizardpages.exsd
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/DescriptionToolTip.java
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/actions/DownloadRuntimeAction.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/configurators/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/configurators/DefaultJBossCentralConfigurator.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/configurators/IJBossCentralConfigurator.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/AutoResizeTableLayout.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/
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/wizard/ContributedPage.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IProjectExamplesWizardPage.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesLocationPage.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesMainPage.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesReadyPage.java
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/NewProjectExamplesWizard2.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ProjectReadyWizard.java
Removed:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/FixDialog.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
Modified:
trunk/download.jboss.org/jbosstools/examples/project-examples-maven-3.3.xml
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/RunProjectExample.java
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.project.examples/build.properties
trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml
trunk/examples/plugins/org.jboss.tools.project.examples/schema/categories.exsd
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/ProjectExamplesHandler.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/xpl/QuickFixPage.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/IImportProjectExample.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ImportDefaultProjectExample.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesJob.java
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectTest.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExample.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/xpl/UpdateMavenProjectJob.java
Log:
JBIDE-10264 Wizard-ify the project examples
Modified:
trunk/download.jboss.org/jbosstools/examples/project-examples-maven-3.3.xml
===================================================================
---
trunk/download.jboss.org/jbosstools/examples/project-examples-maven-3.3.xml 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/download.jboss.org/jbosstools/examples/project-examples-maven-3.3.xml 2012-02-15
22:40:09 UTC (rev 38784)
@@ -223,8 +223,7 @@
<included-projects>jboss-as-kitchensink</included-projects>
<shortDescription>Kitchensink</shortDescription>
<description>
-This is your project! It's a sample, deployable Maven 3 project to help you get your
foot in the door developing with Java EE 6 on JBoss AS 7.
-This project is setup to allow you to create a compliant Java EE 6 application using JSF
2.0, CDI 1.0, EJB 3.1, JPA 2.0 and Bean Validation 1.0.
+This is your project! It's a sample, deployable Maven 3 project to help you get your
foot in the door developing with Java EE 6 on JBoss AS 7. This project is setup to allow
you to create a compliant Java EE 6 application using JSF 2.0, CDI 1.0, EJB 3.1, JPA 2.0
and Bean Validation 1.0.
It includes a persistence unit and some sample persistence and transaction code to help
you get your feet wet with database access in enterprise Java.
</description>
<size>8192</size>
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2012-02-15
22:40:09 UTC (rev 38784)
@@ -32,16 +32,27 @@
org.jboss.tools.portlet.core,
org.eclipse.equinox.p2.operations,
org.eclipse.jst.server.core,
- org.eclipse.core.filesystem;bundle-version="1.3.100"
+ org.eclipse.core.filesystem;bundle-version="1.3.100",
+ org.jboss.tools.runtime.core,
+ org.jboss.tools.runtime.ui,
+ org.eclipse.mylyn.commons.core;bundle-version="3.6.0",
+ org.eclipse.mylyn.discovery.ui;bundle-version="3.6.0",
+ org.eclipse.mylyn.discovery.core;bundle-version="3.6.0",
+ org.eclipse.mylyn.commons.ui;bundle-version="[3.6.0,3.8.0)",
+ org.apache.commons.lang;bundle-version="2.4.0",
+ org.eclipse.jdt.ui;bundle-version="3.7.1"
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.jboss.tools.project.examples,
org.jboss.tools.project.examples.actions,
+ org.jboss.tools.project.examples.configurators,
org.jboss.tools.project.examples.dialog,
org.jboss.tools.project.examples.dialog.xpl,
org.jboss.tools.project.examples.filetransfer,
org.jboss.tools.project.examples.fixes,
org.jboss.tools.project.examples.model,
org.jboss.tools.project.examples.preferences,
+ org.jboss.tools.project.examples.runtimes,
org.jboss.tools.project.examples.wizard
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Service-Component: OSGI-INF/downloadRuntime.xml
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/OSGI-INF/downloadRuntime.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/OSGI-INF/downloadRuntime.xml
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/OSGI-INF/downloadRuntime.xml 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,10 @@
+<?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/build.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/build.properties 2012-02-15
22:20:03 UTC (rev 38783)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/build.properties 2012-02-15
22:40:09 UTC (rev 38784)
@@ -12,4 +12,5 @@
about.properties,\
rhds_wiz.png,\
schema/,\
- jboss_about.png
+ jboss_about.png,\
+ OSGI-INF/
Added: trunk/examples/plugins/org.jboss.tools.project.examples/icons/jboss.png
===================================================================
(Binary files differ)
Property changes on:
trunk/examples/plugins/org.jboss.tools.project.examples/icons/jboss.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/examples/plugins/org.jboss.tools.project.examples/icons/seam16.png
===================================================================
(Binary files differ)
Property changes on:
trunk/examples/plugins/org.jboss.tools.project.examples/icons/seam16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/examples/plugins/org.jboss.tools.project.examples/icons/software.png
===================================================================
(Binary files differ)
Property changes on:
trunk/examples/plugins/org.jboss.tools.project.examples/icons/software.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/examples/plugins/org.jboss.tools.project.examples/icons/wtp_server.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/examples/plugins/org.jboss.tools.project.examples/icons/wtp_server.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml 2012-02-15 22:20:03
UTC (rev 38783)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml 2012-02-15 22:40:09
UTC (rev 38784)
@@ -4,22 +4,27 @@
<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"/>
+
<extension point="org.eclipse.ui.newWizards">
<category
name="%JBoss_Tools_category"
id="org.jboss.ide.eclipse.ui.wizards">
</category>
+ <!--
<wizard
id="org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard"
name="%Project_Examples_wizard"
- class="org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard"
+ class="org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard2"
category="org.jboss.ide.eclipse.ui.wizards"
icon="icons/examples_wiz.gif">
</wizard>
+ -->
<wizard
category="org.eclipse.ui.Examples/org.jboss.tools.project.examples.category"
-
class="org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard"
+
class="org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard2"
icon="icons/examples_wiz.gif"
id="org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard"
name="%Project_Examples_wizard">
@@ -82,5 +87,47 @@
name="Project Examples Categories">
<
url>http://download.jboss.org/jbosstools/examples/project-examples-cat...
</extension>
+
+ <extension
+ point="org.jboss.tools.project.examples.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>
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/schema/categories.exsd
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/schema/categories.exsd 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/schema/categories.exsd 2012-02-15
22:40:09 UTC (rev 38784)
@@ -61,17 +61,6 @@
</documentation>
</annotation>
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- <extension
-
point="org.jboss.tools.project.examples.projectExamplesXml">
- <url>file:/C:/test/projectExamples.xml</url>
-</extension>
- </documentation>
- </annotation>
<annotation>
<appInfo>
Added: trunk/examples/plugins/org.jboss.tools.project.examples/schema/configurators.exsd
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/schema/configurators.exsd
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/schema/configurators.exsd 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,109 @@
+<?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="configurators" name="JBoss Central Configurator"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="configurator"/>
+ </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="configurator">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.central.configurators.IJBossCentralConfigurator"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/schema/downloadruntimes.exsd
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/schema/downloadruntimes.exsd
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/schema/downloadruntimes.exsd 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,127 @@
+<?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>
+ </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/examples/plugins/org.jboss.tools.project.examples/schema/wizardpages.exsd
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/schema/wizardpages.exsd
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/schema/wizardpages.exsd 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,130 @@
+<?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="wizardpages" name="Project Examples Wizard Pages"/>
+ </appInfo>
+ <documentation>
+ Project Examples Wizard Pages
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="page" 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="page">
+ <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="type" type="string"
use="required">
+ <annotation>
+ <documentation>
+ Project Example type
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.project.examples.wizard.IProjectExamplesWizardPage"/>
+ </appInfo>
+ </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/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/DescriptionToolTip.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/DescriptionToolTip.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/DescriptionToolTip.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,69 @@
+/*************************************************************************************
+ * 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;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.window.ToolTip;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+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.Event;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class DescriptionToolTip extends ToolTip {
+
+ private String description;
+
+ public DescriptionToolTip(Control control, String description) {
+ super(control);
+ this.description = description;
+ setHideOnMouseDown(true);
+ setPopupDelay(400);
+
+ }
+
+ @Override
+ protected Composite createToolTipContentArea(Event event, Composite parent) {
+ // Create the content area
+ parent.setLayout(new GridLayout());
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 2;
+ layout.marginLeft = 2;
+ composite.setLayout(layout);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.widthHint = 300;
+ composite.setLayoutData(gd);
+ composite.setBackground(parent.getDisplay().getSystemColor(
+ SWT.COLOR_INFO_BACKGROUND));
+ Text text = new Text(composite,
+ SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ GC gc = new GC(parent);
+ gd.heightHint = Dialog.convertHeightInCharsToPixels(gc
+ .getFontMetrics(), (description.length()/40) + 1);
+ gc.dispose();
+ text.setLayoutData(gd);
+ text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ text.setText(description);
+
+ return composite;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/DownloadRuntimes.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,15 @@
+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-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -19,9 +19,12 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -29,6 +32,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.apache.commons.lang.StringEscapeUtils;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
@@ -52,12 +56,16 @@
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IFileEditorInput;
@@ -67,6 +75,7 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.WorkbenchException;
@@ -91,24 +100,36 @@
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.wst.validation.internal.operations.ValidationBuilder;
-import org.jboss.tools.project.examples.dialog.MarkerDialog;
+import org.jboss.tools.project.examples.configurators.DefaultJBossCentralConfigurator;
+import org.jboss.tools.project.examples.configurators.IJBossCentralConfigurator;
import org.jboss.tools.project.examples.fixes.PluginFix;
import org.jboss.tools.project.examples.fixes.ProjectExamplesFix;
import org.jboss.tools.project.examples.fixes.SeamRuntimeFix;
import org.jboss.tools.project.examples.fixes.WTPRuntimeFix;
import org.jboss.tools.project.examples.model.IImportProjectExample;
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.model.ProjectExampleUtil;
+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;
+import org.jboss.tools.project.examples.wizard.ProjectReadyWizard;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Version;
/**
* The activator class controls the plug-in life cycle
*/
public class ProjectExamplesActivator extends AbstractUIPlugin {
+ private static final int DESCRIPTION_LENGTH = 100;
+
+ public static final String PROPERTY_PROJECT_NAME = "projectName";
//$NON-NLS-1$
+ public static final String PROPERTY_LOCATION_PATH = "locationPath";
//$NON-NLS-1$
+ public static final String PROPERTY_ARTIFACT_ID = "artifactId"; //$NON-NLS-1$
+
private static final String README_HTML = "/readme.html"; //$NON-NLS-1$
private static final String CHEATSHEET_XML = "/cheatsheet.xml"; //$NON-NLS-1$
private static final String PERIOD_CHEATSHEET_XML = "/.cheatsheet.xml";
//$NON-NLS-1$
@@ -133,6 +154,24 @@
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 CLASS = "class"; //$NON-NLS-1$
+
+ private static final String PRIORITY = "priority"; //$NON-NLS-1$
+
+ public static final String CONFIGURATORS_EXTENSION_ID =
"org.jboss.tools.project.examples.configurators"; //$NON-NLS-1$
+
+ public static final String WIZARDPAGES_EXTENSION_ID =
"org.jboss.tools.project.examples.wizardpages"; //$NON-NLS-1$
+
+ private IJBossCentralConfigurator configurator;
+
+ public static final String JBOSS_DISCOVERY_DIRECTORY =
"jboss.discovery.directory.url"; //$NON-NLS-1$
+
+ private static final Object CONFIGURATOR = "configurator"; //$NON-NLS-1$
+
// The shared instance
private static ProjectExamplesActivator plugin;
@@ -160,6 +199,13 @@
private Map<String, IImportProjectExample> importProjectExamplesMap;
private ImportDefaultProjectExample defaultImportProjectExample;
+ private static final String VERSION = "version"; //$NON-NLS-1$
+ private static final String URL = "url"; //$NON-NLS-1$
+
+ private Map<String, DownloadRuntime> downloadRuntimes;
+
+ private Map<String, List<ContributedPage>> contributedPages;
+
/**
* The constructor
*/
@@ -816,25 +862,26 @@
page.setPerspective(persp);
}
- public static void showQuickFix(final List<ProjectExample> projects) {
+ public static void showReadyWizard(final List<ProjectExample> projects) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
-
- Shell shell = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell();
- Dialog dialog = new MarkerDialog(shell, projects);
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ IWizard wizard = new ProjectReadyWizard(projects);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.open();
+// Dialog dialog = new MarkerDialog(shell, projects);
+// dialog.open();
}
});
}
public static void importProjectExamples(
- final List<ProjectExample> selectedProjects, final boolean showQuickFix) {
+ final List<ProjectExample> selectedProjects, IWorkingSet[] workingSets,
Map<String, Object> propertiesMap) {
final NewProjectExamplesJob workspaceJob = new NewProjectExamplesJob(
- Messages.NewProjectExamplesWizard_Downloading, selectedProjects);
+ Messages.NewProjectExamplesWizard_Downloading, selectedProjects, workingSets,
propertiesMap);
workspaceJob.setUser(true);
workspaceJob.addJobChangeListener(new IJobChangeListener() {
@@ -859,14 +906,10 @@
} catch (InterruptedException e) {
return;
}
- if (showQuickFix && projects != null && projects.size() > 0) {
- List<IMarker> markers = ProjectExamplesActivator
- .getMarkers(projects);
- if (markers != null && markers.size() > 0) {
- ProjectExamplesActivator.showQuickFix(projects);
- }
+ if (projects != null && projects.size() > 0) {
+ ProjectExamplesActivator.showReadyWizard(projects);
}
- ProjectExamplesActivator.openWelcome(projects);
+
}
public void running(IJobChangeEvent event) {
@@ -886,4 +929,171 @@
workspaceJob.schedule();
}
+ public Image getImage(ImageDescriptor imageDescriptor) {
+ ImageRegistry imageRegistry = getImageRegistry();
+ String id = getImageId(imageDescriptor);
+ Image image = imageRegistry.get(id);
+ if (image == null) {
+ image = imageDescriptor.createImage(true);
+ imageRegistry.put(id, image);
+ }
+ return image;
+ }
+
+ private String getImageId(ImageDescriptor imageDescriptor) {
+ return PLUGIN_ID + "/" + imageDescriptor.hashCode(); //$NON-NLS-1$
+ }
+
+ public Image getImage(String imagePath) {
+ ImageRegistry registry = getImageRegistry();
+ Image image = registry.get(imagePath);
+ if (image != null) {
+ return image;
+ }
+ ImageDescriptor imageDescriptor = getImageDescriptor(imagePath);
+ image = imageDescriptor.createImage();
+ registry.put(imagePath, image);
+ return image;
+ }
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ public Map<String, List<ContributedPage>> getContributedPages() {
+ if (contributedPages == null) {
+ contributedPages = new HashMap<String, List<ContributedPage>>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry
+ .getExtensionPoint(WIZARDPAGES_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 clazz = configurationElement.getAttribute(CLASS);
+ String priorityString = configurationElement.getAttribute(PRIORITY);
+ int priority = 0;
+ if (priorityString != null) {
+ try {
+ priority = new Integer(priorityString);
+ } catch (NumberFormatException e) {
+ ProjectExamplesActivator.log(e);
+ }
+ }
+ String type = configurationElement.getAttribute(TYPE);
+ ContributedPage contributedPage = new ContributedPage(configurationElement, type,
priority, clazz);
+ List<ContributedPage> contributions = contributedPages.get(type);
+ if (contributions == null) {
+ contributions = new ArrayList<ContributedPage>();
+ contributedPages.put(type, contributions);
+ }
+ contributions.add(contributedPage);
+ Collections.sort(contributions);
+ }
+ }
+ }
+ 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);
+ DownloadRuntime downloadRuntime = new DownloadRuntime(id, name, version, url);
+ downloadRuntimes.put(id, downloadRuntime);
+ }
+ }
+ }
+ return downloadRuntimes;
+ }
+
+ public IJBossCentralConfigurator getConfigurator() {
+ if (configurator == null) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry
+ .getExtensionPoint(CONFIGURATORS_EXTENSION_ID);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ if (extensions.length > 0) {
+ IExtension extension = extensions[0];
+ IConfigurationElement[] configurationElements = extension
+ .getConfigurationElements();
+ for (int j = 0; j < configurationElements.length; j++) {
+ IConfigurationElement configurationElement = configurationElements[j];
+ if (CONFIGURATOR.equals(configurationElement.getName())) {
+ try {
+ configurator = (IJBossCentralConfigurator) configurationElement
+ .createExecutableExtension("class");
+ } catch (CoreException e) {
+ ProjectExamplesActivator.log(e);
+ continue;
+ }
+ break;
+ }
+ }
+
+ }
+ if (configurator == null) {
+ configurator = new DefaultJBossCentralConfigurator();
+ }
+ }
+ return configurator;
+ }
+
+ public static Dictionary<Object, Object> getEnvironment() {
+ Dictionary<Object, Object> environment = new Hashtable<Object, Object>(
+ System.getProperties());
+ Bundle bundle = Platform.getBundle("org.jboss.tools.central"); //$NON-NLS-1$
+ Version version = bundle.getVersion();
+ environment.put("org.jboss.tools.central.version", version.toString());
//$NON-NLS-1$
+ environment.put(
+ "org.jboss.tools.central.version.major", version.getMajor());
//$NON-NLS-1$
+ environment.put(
+ "org.jboss.tools.central.version.minor", version.getMinor());
//$NON-NLS-1$
+ environment.put(
+ "org.jboss.tools.central.version.micro", version.getMicro());
//$NON-NLS-1$
+ return environment;
+ }
+
+ public static String getShortDescription(String description) {
+ if (description.length() <= DESCRIPTION_LENGTH) {
+ return description;
+ }
+ char[] chars = StringEscapeUtils.unescapeHtml(description.trim()).toCharArray();
+ StringBuffer buffer = new StringBuffer();
+ int i = 0;
+ for (char c:chars) {
+ if (i++ < DESCRIPTION_LENGTH) {
+ buffer.append(c);
+ } else {
+ if ( (c == '_') ||
+ (c >= 'a' && c <= 'z') ||
+ (c >= 'a' && c <= 'Z') ||
+ (c >= '0' && c <= '9') ) {
+ buffer.append(c);
+ } else {
+ break;
+ }
+ }
+ }
+ if (buffer.length() > 0) {
+ buffer.append("..."); //$NON-NLS-1$
+ }
+ return buffer.toString();
+ }
}
Added:
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
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/actions/DownloadRuntimeAction.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,70 @@
+/*************************************************************************************
+ * 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.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();
+
+ }
+
+}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/actions/ProjectExamplesHandler.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/actions/ProjectExamplesHandler.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/actions/ProjectExamplesHandler.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -1,5 +1,5 @@
/*************************************************************************************
- * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * Copyright (c) 2008-2012 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
@@ -16,7 +16,7 @@
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard;
+import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard2;
/**
* @author snjeza
@@ -25,7 +25,7 @@
public class ProjectExamplesHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
- Wizard wizard = new NewProjectExamplesWizard();
+ Wizard wizard = new NewProjectExamplesWizard2();
WizardDialog dialog = new
WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
dialog.open();
return null;
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/configurators/DefaultJBossCentralConfigurator.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/configurators/DefaultJBossCentralConfigurator.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/configurators/DefaultJBossCentralConfigurator.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,89 @@
+/*************************************************************************************
+ * Copyright (c) 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.configurators;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+
+/**
+ *
+ * @author snjeza, nboldt
+ *
+ */
+public class DefaultJBossCentralConfigurator implements
+ IJBossCentralConfigurator {
+
+ // TODO: for GA, change this from /development/indigo/ to /stable/indigo/
+ private static final String JBOSS_DIRECTORY_URL_DEFAULT =
"http://download.jboss.org/jbosstools/updates/development/indigo/jbosstools-directory.xml";
//$NON-NLS-1$
+
+ // see pom.xml for actual value -- this is passed it at build-time via Maven
+ private static final String JBOSS_DIRECTORY_URL =
"${jboss.discovery.directory.url}"; //$NON-NLS-1$
+
+ private static final String TWITTER_LINK ="http://twitter.com/#!/jbosstools";
//$NON-NLS-1$
+
+ private static final String BLOGS_URL = "http://planet.jboss.org/feeds/blogs";
//$NON-NLS-1$
+
+ private static final String NEWS_URL = "http://planet.jboss.org/feeds/news";
//$NON-NLS-1$
+
+ private Image headerImage;
+
+ @Override
+ public String[] getMainToolbarCommandIds() {
+ return new String[] {"org.jboss.tools.central.openJBossToolsHome",
//$NON-NLS-1$
+ "org.jboss.tools.central.favoriteAtEclipseMarketplace", //$NON-NLS-1$
+ "org.jboss.tools.central.preferences"}; //$NON-NLS-1$
+ }
+
+ @Override
+ public String getJBossDiscoveryDirectory() {
+ // use commandline override -Djboss.discovery.directory.url
+ String directory =
System.getProperty(ProjectExamplesActivator.JBOSS_DISCOVERY_DIRECTORY, null);
+ if (directory == null) {
+ // else use Maven-generated value; fall back to default
+ return JBOSS_DIRECTORY_URL.equals("${" +
"jboss.discovery.directory.url" + "}") ? JBOSS_DIRECTORY_URL_DEFAULT :
JBOSS_DIRECTORY_URL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ return directory;
+ }
+
+ @Override
+ public String getTwitterLink() {
+ return TWITTER_LINK;
+ }
+
+ @Override
+ public String getBlogsUrl() {
+ return BLOGS_URL;
+ }
+
+ @Override
+ public String getNewsUrl() {
+ return NEWS_URL;
+ }
+
+ @Override
+ public List<String> getWizardIds() {
+ List<String> wizardIds = new ArrayList<String>();
+
wizardIds.add("org.eclipse.jst.servlet.ui.project.facet.WebProjectWizard");
//$NON-NLS-1$
+
wizardIds.add("org.jboss.ide.eclipse.as.openshift.express.ui.wizard.createNewApplicationWizard");
//$NON-NLS-1$
+ return wizardIds;
+ }
+
+ @Override
+ public Image getHeaderImage() {
+ if (headerImage == null) {
+ headerImage =
ProjectExamplesActivator.getDefault().getImage("/icons/jboss.png");
//$NON-NLS-1$
+ }
+ return headerImage;
+ }
+}
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/configurators/IJBossCentralConfigurator.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/configurators/IJBossCentralConfigurator.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/configurators/IJBossCentralConfigurator.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,32 @@
+/*************************************************************************************
+ * Copyright (c) 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.configurators;
+
+import java.util.List;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public interface IJBossCentralConfigurator {
+
+ String[] getMainToolbarCommandIds();
+ String getJBossDiscoveryDirectory();
+ String getTwitterLink();
+ String getBlogsUrl();
+ String getNewsUrl();
+ List<String> getWizardIds();
+ Image getHeaderImage();
+
+}
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/AutoResizeTableLayout.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/AutoResizeTableLayout.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/AutoResizeTableLayout.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,129 @@
+/*************************************************************************************
+ * 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.List;
+
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class AutoResizeTableLayout extends TableLayout implements
+ ControlListener {
+
+ private final Table table;
+ private List<ColumnLayoutData> columns = new
ArrayList<ColumnLayoutData>();
+ private boolean autosizing = false;
+
+ public AutoResizeTableLayout(Table table) {
+ this.table = table;
+ table.addControlListener(this);
+ }
+
+ public void addColumnData(ColumnLayoutData data) {
+ columns.add(data);
+ super.addColumnData(data);
+ }
+
+ public void controlMoved(ControlEvent e) {
+ }
+
+ public void controlResized(ControlEvent e) {
+ if (autosizing) {
+ return;
+ }
+ autosizing = true;
+ try {
+ autoSizeColumns();
+ } finally {
+ autosizing = false;
+ }
+ }
+
+ private void autoSizeColumns() {
+ int width = table.getClientArea().width;
+ if (width <= 1) {
+ return;
+ }
+
+ TableColumn[] tableColumns = table.getColumns();
+ int size =
+ Math.min(columns.size(), tableColumns.length);
+ int[] widths = new int[size];
+ int fixedWidth = 0;
+ int numberOfWeightColumns = 0;
+ int totalWeight = 0;
+
+ // First calc space occupied by fixed columns.
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnPixelData) {
+ int pixels = ((ColumnPixelData)col).width;
+ widths[i] = pixels;
+ fixedWidth += pixels;
+ } else if (col instanceof ColumnWeightData) {
+ ColumnWeightData cw = (ColumnWeightData)col;
+ numberOfWeightColumns++;
+ int weight = cw.weight;
+ totalWeight += weight;
+ } else {
+ throw new IllegalStateException("Unknown column layout data");
+ }
+ }
+
+ // Do we have columns that have a weight?
+ if (numberOfWeightColumns > 0) {
+ // Now, distribute the rest
+ // to the columns with weight.
+ int rest = width - fixedWidth;
+ int totalDistributed = 0;
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnWeightData) {
+ ColumnWeightData cw = (ColumnWeightData)col;
+ int weight = cw.weight;
+ int pixels = totalWeight == 0 ? 0 : weight * rest / totalWeight;
+ totalDistributed += pixels;
+ widths[i] = pixels;
+ }
+ }
+
+ // Distribute any remaining pixels
+ // to columns with weight.
+ int diff = rest - totalDistributed;
+ for (int i = 0; diff > 0; i++) {
+ if (i == size) {
+ i = 0;
+ }
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnWeightData) {
+ ++widths[i];
+ --diff;
+ }
+ }
+ }
+
+ for (int i = 0; i < size; i++) {
+ if (tableColumns[i].getWidth() != widths[i]) {
+ tableColumns[i].setWidth(widths[i]);
+ }
+
+ }
+
+ }
+
+}
Added:
trunk/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
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeDialog.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,442 @@
+/*************************************************************************************
+ * 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.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.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;
+
+/**
+ * @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 = 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);
+ //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) {
+ ProjectExamplesActivator.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()) {
+ ProjectExamplesActivator.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()) {
+ ProjectExamplesActivator.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) {
+ ProjectExamplesActivator.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();
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeViewerDialog.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,188 @@
+/*************************************************************************************
+ * 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.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) {
+ 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);
+ }
+
+}
Deleted:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/FixDialog.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/FixDialog.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/FixDialog.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -1,223 +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.dialog;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.project.examples.Messages;
-import org.jboss.tools.project.examples.model.ProjectExample;
-import org.jboss.tools.project.examples.model.ProjectFix;
-import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizardPage;
-
-/**
- *
- * @author snjeza
- *
- */
-public class FixDialog extends Dialog {
-
- private static final int FIX_BUTTON = 1;
- private TableViewer tableViewer;
- private List<ProjectFix> fixes;
- private Button fixButton;
- private ProjectFix fix;
- private NewProjectExamplesWizardPage page;
-
- public FixDialog(Shell parentShell, NewProjectExamplesWizardPage page) {
- super(parentShell);
- setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
- | SWT.MODELESS | SWT.RESIZE | getDefaultOrientation());
- this.page = page;
- refresh();
- }
-
- private void refresh() {
- IStructuredSelection selection = page.getSelection();
- Iterator iterator = selection.iterator();
- fixes = new ArrayList<ProjectFix>();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object instanceof ProjectExample) {
- ProjectExample project = (ProjectExample) object;
- fixes.addAll(project.getUnsatisfiedFixes());
- }
-
- }
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite area = (Composite) super.createDialogArea(parent);
- Composite contents = new Composite(area, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 300;
- contents.setLayoutData(gd);
- contents.setLayout(new GridLayout());
- getShell().setText(Messages.FixDialog_Requirement_details);
- applyDialogFont(contents);
- initializeDialogUnits(area);
-
- Label fixesLabel = new Label(contents, SWT.NULL);
- fixesLabel.setText(Messages.FixDialog_Requirements);
- tableViewer = new TableViewer(contents, SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.BORDER | SWT.SINGLE);
- Table table = tableViewer.getTable();
- gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 100;
- table.setLayoutData(gd);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- String[] columnNames = new String[] { Messages.FixDialog_Type,
Messages.FixDialog_Short_description };
- int[] columnWidths = new int[] { 200, 350 };
-
- for (int i = 0; i < columnNames.length; i++) {
- TableColumn tc = new TableColumn(table, SWT.LEFT);
- tc.setText(columnNames[i]);
- tc.setWidth(columnWidths[i]);
- }
-
- tableViewer.setLabelProvider(new FixLabelProvider());
- tableViewer.setContentProvider(new FixContentProvider(fixes));
- tableViewer.setInput(fixes);
-
- Label descriptionLabel = new Label(contents, SWT.NONE);
- descriptionLabel.setText(Messages.FixDialog_Description);
- final Text description = new Text(contents, SWT.BORDER | SWT.MULTI | SWT.WRAP |
SWT.READ_ONLY);
- gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL |
GridData.GRAB_VERTICAL);
- gd.heightHint=50;
- description.setLayoutData(gd);
-
- tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- description.setText(""); //$NON-NLS-1$
- ISelection selection = event.getSelection();
- fix = null;
- fixButton.setEnabled(false);
- if (selection instanceof IStructuredSelection) {
- Object object = ((IStructuredSelection) selection).getFirstElement();
- if (object instanceof ProjectFix) {
- fix = (ProjectFix) object;
- fixButton.setEnabled(fix.isFixable());
- description.setText(fix.getProperties().get(ProjectFix.DESCRIPTION));
- }
- }
- }
-
- });
-
- return area;
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- fixButton = createButton(parent, FIX_BUTTON, Messages.FixDialog_Fix, true);
- if (fix == null) {
- fixButton.setEnabled(false);
- } else {
- fixButton.setEnabled(fix.isFixable());
- }
- fixButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (fix != null) {
- fix.fix();
- page.refresh(true);
- refresh();
- tableViewer.setInput(fixes);
- //tableViewer.refresh();
- }
- }
-
- });
- createButton(parent, IDialogConstants.OK_ID, Messages.FixDialog_Finish,
- true);
- }
-
- @Override
- protected void buttonPressed(int buttonId) {
- if (FIX_BUTTON != buttonId) {
- super.buttonPressed(buttonId);
- }
- }
- private class FixLabelProvider extends LabelProvider implements
- ITableLabelProvider {
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof ProjectFix) {
- ProjectFix fix = (ProjectFix) element;
- if (columnIndex == 0) {
- return fix.getType();
- }
- if (columnIndex == 1) {
- return fix.getShortDescription();
- }
- }
- return null;
- }
- }
-
- private class FixContentProvider implements IStructuredContentProvider {
-
- private List<ProjectFix> fixes;
-
- public FixContentProvider(List<ProjectFix> fixes) {
- this.fixes = fixes;
- }
-
- public Object[] getElements(Object inputElement) {
- return fixes.toArray();
- }
-
- public void dispose() {
-
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- fixes = (List<ProjectFix>) newInput;
- }
-
- }
-
-}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/xpl/QuickFixPage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/xpl/QuickFixPage.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/xpl/QuickFixPage.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -163,8 +163,10 @@
Dialog.applyDialogFont(control);
- resolutionsList.setSelection(new StructuredSelection(resolutionsList
- .getElementAt(0)));
+ if (resolutionsList.getList().getItemCount() > 0) {
+ resolutionsList.setSelection(new StructuredSelection(
+ resolutionsList.getElementAt(0)));
+ }
markersTable.setAllChecked(true);
}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2012-02-15
22:40:09 UTC (rev 38784)
@@ -57,7 +57,7 @@
ProjectExamplesPreferencePage_Show_experimental_sites=Show experimental sites
ProjectExamplesPreferencePage_Show_invalid_sites=Show invalid sites
ProjectExamplesPreferencePage_Sites=Sites
-ProjectExamplesPreferencePage_Use_default_workspace_location=Use default workspace
location
+ProjectExamplesPreferencePage_Use_default_workspace_location=Use default location
ProjectFix_Missing_Drools_Runtime=Missing Drools Runtime
ProjectFix_Missing_plugin=Missing plugin
ProjectFix_Missing_Seam_Runtime=Missing Seam Runtime
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/IImportProjectExample.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/IImportProjectExample.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/IImportProjectExample.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -12,6 +12,7 @@
package org.jboss.tools.project.examples.model;
import java.io.File;
+import java.util.Map;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -23,7 +24,7 @@
public interface IImportProjectExample {
boolean importProject(ProjectExample projectDescription, File file,
- IProgressMonitor monitor) throws Exception;
+ Map<String, Object> propertiesMap, IProgressMonitor monitor) throws Exception;
void fix(ProjectExample project, IProgressMonitor monitor);
Added:
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
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/runtimes/DownloadRuntime.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,88 @@
+/*************************************************************************************
+ * 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;
+
+ 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 + "]";
+ }
+
+}
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ContributedPage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ContributedPage.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ContributedPage.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,66 @@
+package org.jboss.tools.project.examples.wizard;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+
+public class ContributedPage implements Comparable<ContributedPage> {
+
+ private String type;
+ private int priority;
+ private IConfigurationElement configurationElement;
+ private String clazz;
+
+ public ContributedPage(IConfigurationElement configurationElement,
+ String type, int priority, String clazz) {
+ super();
+ this.configurationElement = configurationElement;
+ this.type = type;
+ this.priority = priority;
+ this.clazz = clazz;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+ public IConfigurationElement getConfigurationElement() {
+ return configurationElement;
+ }
+
+ public void setConfigurationElement(
+ IConfigurationElement configurationElement) {
+ this.configurationElement = configurationElement;
+ }
+
+ public String getClazz() {
+ return clazz;
+ }
+
+ public void setClazz(String clazz) {
+ this.clazz = clazz;
+ }
+
+ @Override
+ public int compareTo(ContributedPage o) {
+ if (o == null)
+ return 1;
+ int other = o.getPriority();
+ if (other < this.priority)
+ return 1;
+ else if (other > this.priority)
+ return -1;
+ return 0;
+ }
+
+}
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IProjectExamplesWizardPage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IProjectExamplesWizardPage.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/IProjectExamplesWizardPage.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,17 @@
+package org.jboss.tools.project.examples.wizard;
+
+import java.util.Map;
+
+import org.eclipse.jface.wizard.IWizardPage;
+import org.jboss.tools.project.examples.model.ProjectExample;
+
+public interface IProjectExamplesWizardPage extends IWizardPage {
+
+ boolean finishPage();
+
+ String getProjectExampleType();
+
+ void setProjectExample(ProjectExample projectExample);
+
+ Map<String, Object> getPropertiesMap();
+}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ImportDefaultProjectExample.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ImportDefaultProjectExample.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ImportDefaultProjectExample.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
+import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
@@ -49,7 +50,7 @@
@Override
public boolean importProject(ProjectExample projectDescription, File file,
- IProgressMonitor monitor) throws Exception {
+ Map<String, Object> propertiesMap, IProgressMonitor monitor) throws Exception {
List<ProjectExample> projects = new ArrayList<ProjectExample>();
if (projectDescription.getIncludedProjects() == null) {
boolean ret = importSingleProject(projectDescription, file, monitor);
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesJob.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesJob.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesJob.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -2,16 +2,22 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.WorkspaceJob;
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.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.project.examples.Messages;
import org.jboss.tools.project.examples.ProjectExamplesActivator;
@@ -22,10 +28,14 @@
private List<ProjectExample> selectedProjects;
private List<ProjectExample> projects = new ArrayList<ProjectExample>();
+ private IWorkingSet[] workingSets;
+ private Map<String, Object> propertiesMap;
- public NewProjectExamplesJob(String name, List<ProjectExample> selectedProjects)
{
+ public NewProjectExamplesJob(String name, List<ProjectExample> selectedProjects,
IWorkingSet[] workingSets, Map<String, Object> propertiesMap) {
super(name);
this.selectedProjects = selectedProjects;
+ this.workingSets = workingSets;
+ this.propertiesMap = propertiesMap;
}
@Override
@@ -57,11 +67,19 @@
});
return Status.CANCEL_STATUS;
}
- if (importProjectExample.importProject(project, project.getFile(), monitor)) {
+ if (importProjectExample.importProject(project, project.getFile(), propertiesMap,
monitor)) {
importProjectExample.fix(project, monitor);
} else {
return Status.CANCEL_STATUS;
}
+ if (workingSets != null && workingSets.length > 0 &&
project.getIncludedProjects() != null) {
+ for (String projectName:project.getIncludedProjects()) {
+ IProject eclipseProject =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (eclipseProject != null && eclipseProject.exists()) {
+ PlatformUI.getWorkbench().getWorkingSetManager().addToWorkingSets(eclipseProject,
workingSets);
+ }
+ }
+ }
}
} catch (final Exception e) {
Display.getDefault().syncExec(new Runnable() {
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesLocationPage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesLocationPage.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesLocationPage.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,295 @@
+package org.jboss.tools.project.examples.wizard;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
+import org.eclipse.jdt.internal.ui.workingsets.IWorkingSetIDs;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.dialogs.WorkingSetConfigurationBlock;
+import org.jboss.tools.project.examples.Messages;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.model.ProjectExample;
+
+public class NewProjectExamplesLocationPage extends WizardPage {
+
+ private final static String RESOURCE= "org.eclipse.ui.resourceWorkingSetPage";
//$NON-NLS-1$
+ private final static String JAVA= "org.eclipse.jdt.ui.JavaWorkingSetPage";
//$NON-NLS-1$
+ private final static String OTHERS=
"org.eclipse.jdt.internal.ui.OthersWorkingSet"; //$NON-NLS-1$
+
+ private Text outputDirectoryText;
+ private Button isWorkspace;
+ private WorkingSetGroup fWorkingSetGroup;
+
+ protected NewProjectExamplesLocationPage() {
+ super("org.jboss.tools.project.examples.location"); //$NON-NLS-1$
+ setTitle( "Location" );
+ setDescription( "Project Example Location and Workspace" );
+ setImageDescriptor(
ProjectExamplesActivator.imageDescriptorFromPlugin(ProjectExamplesActivator.PLUGIN_ID,
"icons/new_wiz.gif")); //$NON-NLS-1$
+ fWorkingSetGroup= new WorkingSetGroup();
+ setWorkingSets(new IWorkingSet[0]);
+ }
+
+ public void setWorkingSets(IWorkingSet[] workingSets) {
+ if (workingSets == null) {
+ throw new IllegalArgumentException();
+ }
+ fWorkingSetGroup.setWorkingSets(workingSets);
+ }
+
+ public IWorkingSet[] getWorkingSets() {
+ return fWorkingSetGroup.getSelectedWorkingSets();
+ }
+
+ protected Control createWorkingSetControl(Composite composite) {
+ return fWorkingSetGroup.createControl(composite);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1,false));
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ composite.setLayoutData(gd);
+ Dialog.applyDialogFont(composite);
+ setControl(composite);
+
+ Group outputDirectoryGroup = new Group(composite, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ outputDirectoryGroup.setLayout(layout);
+ outputDirectoryGroup.setText(Messages.ProjectExamplesPreferencePage_Output_directory);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ outputDirectoryGroup.setLayoutData(gd);
+
+ isWorkspace = new Button(outputDirectoryGroup, SWT.CHECK);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.horizontalSpan = 2;
+ isWorkspace.setLayoutData(gd);
+ isWorkspace.setText(Messages.ProjectExamplesPreferencePage_Use_default_workspace_location);
+ isWorkspace.setSelection(ProjectExamplesActivator.getDefault().getPreferenceStore().getBoolean(ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT));
+
+ outputDirectoryText = new Text(outputDirectoryGroup, SWT.SINGLE|SWT.BORDER);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.verticalAlignment = SWT.CENTER;
+ outputDirectoryText.setLayoutData(gd);
+ IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
+ String outputDirectoryValue =
store.getString(ProjectExamplesActivator.PROJECT_EXAMPLES_OUTPUT_DIRECTORY);
+ if (outputDirectoryValue == null || outputDirectoryValue.isEmpty()) {
+ final IPath path= Platform.getLocation();
+ outputDirectoryValue = path.toOSString();
+ }
+ outputDirectoryText.setText(outputDirectoryValue == null ? "" :
outputDirectoryValue); //$NON-NLS-1$
+ final Button outputDirectoryBrowse = new Button(outputDirectoryGroup, SWT.PUSH);
+ outputDirectoryBrowse.setText(Messages.Browse);
+ outputDirectoryBrowse.addSelectionListener(new SelectionAdapter(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SINGLE);
+ String value = outputDirectoryText.getText();
+ if (value.trim().length() == 0) {
+ value = Platform.getLocation().toOSString();
+ }
+ dialog.setFilterPath(value);
+
+ String result = dialog.open();
+ if (result == null || result.trim().length() == 0) {
+ return;
+ }
+ outputDirectoryText.setText(result);
+
+ }
+
+ });
+ enableControls(outputDirectoryBrowse);
+
+ isWorkspace.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ enableControls(outputDirectoryBrowse);
+ }
+
+ });
+
+ Control workingSetControl= createWorkingSetControl(composite);
+ workingSetControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ setPageComplete(true);
+ }
+
+ public void init(IStructuredSelection selection, IWorkbenchPart activePart) {
+ setWorkingSets(getSelectedWorkingSet(selection, activePart));
+ }
+
+ private static final IWorkingSet[] EMPTY_WORKING_SET_ARRAY = new IWorkingSet[0];
+
+ private IWorkingSet[] getSelectedWorkingSet(IStructuredSelection selection,
IWorkbenchPart activePart) {
+ IWorkingSet[] selected = getSelectedWorkingSet(selection);
+ if (selected != null && selected.length > 0) {
+ for (int i= 0; i < selected.length; i++) {
+ if (!isValidWorkingSet(selected[i]))
+ return EMPTY_WORKING_SET_ARRAY;
+ }
+ return selected;
+ }
+
+ if (!(activePart instanceof PackageExplorerPart))
+ return EMPTY_WORKING_SET_ARRAY;
+
+ PackageExplorerPart explorerPart= (PackageExplorerPart) activePart;
+ if (explorerPart.getRootMode() == PackageExplorerPart.PROJECTS_AS_ROOTS) {
+ //Get active filter
+ IWorkingSet filterWorkingSet= explorerPart.getFilterWorkingSet();
+ if (filterWorkingSet == null)
+ return EMPTY_WORKING_SET_ARRAY;
+
+ if (!isValidWorkingSet(filterWorkingSet))
+ return EMPTY_WORKING_SET_ARRAY;
+
+ return new IWorkingSet[] {filterWorkingSet};
+ } else {
+ //If we have been gone into a working set return the working set
+ Object input= explorerPart.getViewPartInput();
+ if (!(input instanceof IWorkingSet))
+ return EMPTY_WORKING_SET_ARRAY;
+
+ IWorkingSet workingSet= (IWorkingSet)input;
+ if (!isValidWorkingSet(workingSet))
+ return EMPTY_WORKING_SET_ARRAY;
+
+ return new IWorkingSet[] {workingSet};
+ }
+ }
+
+ private IWorkingSet[] getSelectedWorkingSet(IStructuredSelection selection) {
+ if (!(selection instanceof ITreeSelection))
+ return EMPTY_WORKING_SET_ARRAY;
+
+ ITreeSelection treeSelection= (ITreeSelection) selection;
+ if (treeSelection.isEmpty())
+ return EMPTY_WORKING_SET_ARRAY;
+
+ List<?> elements= treeSelection.toList();
+ if (elements.size() == 1) {
+ Object element= elements.get(0);
+ TreePath[] paths= treeSelection.getPathsFor(element);
+ if (paths.length != 1)
+ return EMPTY_WORKING_SET_ARRAY;
+
+ TreePath path= paths[0];
+ if (path.getSegmentCount() == 0)
+ return EMPTY_WORKING_SET_ARRAY;
+
+ Object candidate= path.getSegment(0);
+ if (!(candidate instanceof IWorkingSet))
+ return EMPTY_WORKING_SET_ARRAY;
+
+ IWorkingSet workingSetCandidate= (IWorkingSet) candidate;
+ if (isValidWorkingSet(workingSetCandidate))
+ return new IWorkingSet[] { workingSetCandidate };
+
+ return EMPTY_WORKING_SET_ARRAY;
+ }
+
+ ArrayList<IWorkingSet> result= new ArrayList<IWorkingSet>();
+ for (Iterator<?> iterator= elements.iterator(); iterator.hasNext();) {
+ Object element= iterator.next();
+ if (element instanceof IWorkingSet && isValidWorkingSet((IWorkingSet)
element)) {
+ result.add((IWorkingSet) element);
+ }
+ }
+ return result.toArray(new IWorkingSet[result.size()]);
+ }
+
+
+ private static boolean isValidWorkingSet(IWorkingSet workingSet) {
+ String id= workingSet.getId();
+ if (!JAVA.equals(id) && !RESOURCE.equals(id))
+ return false;
+
+ if (workingSet.isAggregateWorkingSet())
+ return false;
+
+ return true;
+ }
+
+ protected void enableControls(Button outputDirectoryBrowse) {
+ outputDirectoryText.setEnabled(!isWorkspace.getSelection());
+ outputDirectoryBrowse.setEnabled(!isWorkspace.getSelection());
+ }
+
+ private final class WorkingSetGroup {
+
+ private WorkingSetConfigurationBlock fWorkingSetBlock;
+
+ public WorkingSetGroup() {
+ String[] workingSetIds= new String[] { JAVA, RESOURCE };
+ fWorkingSetBlock= new WorkingSetConfigurationBlock(workingSetIds,
ProjectExamplesActivator.getDefault().getDialogSettings());
+ //fWorkingSetBlock.setDialogMessage(NewWizardMessages.NewJavaProjectWizardPageOne_WorkingSetSelection_message);
+ }
+
+ public Control createControl(Composite composite) {
+ Group workingSetGroup= new Group(composite, SWT.NONE);
+ workingSetGroup.setFont(composite.getFont());
+ workingSetGroup.setText("Working sets");
+ workingSetGroup.setLayout(new GridLayout(1, false));
+
+ fWorkingSetBlock.createContent(workingSetGroup);
+
+ return workingSetGroup;
+ }
+
+
+ public void setWorkingSets(IWorkingSet[] workingSets) {
+ fWorkingSetBlock.setWorkingSets(workingSets);
+ }
+
+ public IWorkingSet[] getSelectedWorkingSets() {
+ return fWorkingSetBlock.getSelectedWorkingSets();
+ }
+ }
+
+ @Override
+ public IWizardPage getNextPage() {
+ IWizard wizard = getWizard();
+ if (wizard instanceof NewProjectExamplesWizard2) {
+ ProjectExample projectExample =
((NewProjectExamplesWizard2)wizard).getSelectedProjectExample();
+ if (projectExample != null && projectExample.getImportType() != null) {
+ List<IProjectExamplesWizardPage> pages =
((NewProjectExamplesWizard2)wizard).getContributedPages();
+ for (IProjectExamplesWizardPage page:pages) {
+ if (projectExample.getImportType().equals(page.getProjectExampleType())) {
+ return page;
+ }
+ }
+ }
+ //return ((NewProjectExamplesWizard2)wizard).getReadyPage();
+ }
+ return null;
+ }
+
+}
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesMainPage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesMainPage.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesMainPage.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,416 @@
+/*************************************************************************************
+ * 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.wizard;
+
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.model.AdaptableList;
+import org.jboss.tools.project.examples.Messages;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.model.IImportProjectExample;
+import org.jboss.tools.project.examples.model.IProjectExampleSite;
+import org.jboss.tools.project.examples.model.ProjectExample;
+import org.jboss.tools.project.examples.model.ProjectExampleCategory;
+import org.jboss.tools.project.examples.model.ProjectExampleUtil;
+import org.jboss.tools.project.examples.model.ProjectFix;
+
+/**
+ * @author snjeza
+ *
+ */
+public class NewProjectExamplesMainPage extends WizardPage {
+
+ //private static final int DEFAULT_HEIGHT = 430;
+ private static final int DEFAULT_WIDTH = 600;
+ private IStructuredSelection selection;
+ private Combo siteCombo;
+ private List<ProjectExampleCategory> categories;
+ private Text descriptionText;
+ private NewProjectExamplesRequirementsPage requirementsPage;
+ //private NewProjectExamplesReadyPage readyPage;
+ private List<IProjectExamplesWizardPage> pages;
+ private ProjectExample selectedProject;
+
+ public NewProjectExamplesMainPage(NewProjectExamplesRequirementsPage requirementsPage,
List<IProjectExamplesWizardPage> pages) {
+ super("org.jboss.tools.project.examples.main"); //$NON-NLS-1$
+ setTitle( Messages.NewProjectExamplesWizardPage_Project_Example );
+ setDescription( Messages.NewProjectExamplesWizardPage_Import_Project_Example );
+ setImageDescriptor(
ProjectExamplesActivator.imageDescriptorFromPlugin(ProjectExamplesActivator.PLUGIN_ID,
"icons/new_wiz.gif")); //$NON-NLS-1$
+ this.requirementsPage = requirementsPage;
+ //this.readyPage = readyPage;
+ this.pages = pages;
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent,SWT.NONE);
+ composite.setLayout(new GridLayout(1,false));
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ composite.setLayoutData(gd);
+
+ Composite siteComposite = new Composite(composite,SWT.NONE);
+ GridLayout gridLayout = new GridLayout(2,false);
+ gridLayout.marginHeight = 0;
+ gridLayout.marginWidth = 0;
+ siteComposite.setLayout(gridLayout);
+ gd = new GridData(SWT.FILL, SWT.BEGINNING, false, false);
+ siteComposite.setLayoutData(gd);
+
+ final Button button = new Button(siteComposite,SWT.CHECK);
+ gd = new GridData(SWT.FILL, SWT.BEGINNING, false, false);
+ gd.horizontalSpan = 2;
+ button.setLayoutData(gd);
+ button.setText(Messages.ProjectExamplesPreferencePage_Show_experimental_sites);
+ final IPreferenceStore store =
ProjectExamplesActivator.getDefault().getPreferenceStore();
+ button.setSelection(store.getBoolean(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES));
+
+ new Label(siteComposite,SWT.NONE).setText(Messages.NewProjectExamplesWizardPage_Site);
+ siteCombo = new Combo(siteComposite,SWT.READ_ONLY);
+ siteCombo.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+
+ new Label(composite,SWT.NONE).setText(Messages.NewProjectExamplesWizardPage_Projects);
+
+ final ProjectExamplesPatternFilter filter = new ProjectExamplesPatternFilter();
+
+ int styleBits = SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP;
+ final FilteredTree filteredTree = new FilteredTree(composite, styleBits, filter,
true);
+ filteredTree.setBackground(parent.getDisplay().getSystemColor(
+ SWT.COLOR_WIDGET_BACKGROUND));
+ final TreeViewer viewer = filteredTree.getViewer();
+ Tree tree = viewer.getTree();
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ GC gc = new GC(parent);
+ gd.heightHint = Dialog.convertHeightInCharsToPixels(gc
+ .getFontMetrics(), 9);
+ gc.dispose();
+ tree.setLayoutData(gd);
+ tree.setFont(parent.getFont());
+
+ viewer.setLabelProvider(new ProjectLabelProvider());
+ viewer.setContentProvider(new ProjectContentProvider());
+
+ final SiteFilter siteFilter = new SiteFilter();
+ viewer.addFilter(siteFilter);
+
+ Label descriptionLabel = new Label(composite,SWT.NONE);
+ descriptionLabel.setText(Messages.NewProjectExamplesWizardPage_Description);
+ descriptionText = new Text(composite,SWT.H_SCROLL | SWT.V_SCROLL
+ | SWT.READ_ONLY | SWT.BORDER | SWT.WRAP);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gc = new GC(parent);
+ gd.heightHint = Dialog.convertHeightInCharsToPixels(gc
+ .getFontMetrics(), 6);
+ gc.dispose();
+ descriptionText.setLayoutData(gd);
+
+ Composite internal = new Composite(composite, SWT.NULL);
+ internal.setLayout(new GridLayout(2,false));
+ gd = new GridData(GridData.FILL, GridData.FILL, true, false);
+ gd.widthHint = DEFAULT_WIDTH;
+ internal.setLayoutData(gd);
+
+ Label projectNameLabel = new Label(internal,SWT.NULL);
+ projectNameLabel.setText(Messages.NewProjectExamplesWizardPage_Project_name);
+ final Text projectName = new Text(internal,SWT.BORDER | SWT.READ_ONLY);
+ projectName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label projectSizeLabel = new Label(internal,SWT.NULL);
+ projectSizeLabel.setText(Messages.NewProjectExamplesWizardPage_Project_size);
+ final Text projectSize = new Text(internal,SWT.BORDER | SWT.READ_ONLY);
+ projectSize.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label projectURLLabel = new Label(internal,SWT.NULL);
+ projectURLLabel.setText(Messages.NewProjectExamplesWizardPage_URL);
+ final Text projectURL = new Text(internal,SWT.BORDER | SWT.READ_ONLY);
+ projectURL.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ selection = (IStructuredSelection) event.getSelection();
+ Object selected = selection.getFirstElement();
+ if (selected instanceof ProjectExample && selection.size() == 1) {
+ selectedProject = (ProjectExample) selected;
+ descriptionText.setText(selectedProject.getDescription());
+ projectName.setText(selectedProject.getName());
+ projectURL.setText(selectedProject.getUrl());
+ projectSize.setText(selectedProject.getSizeAsText());
+ requirementsPage.setProjectExample(selectedProject);
+ //readyPage.setProjectExample(selectedProject);
+ String projectType = selectedProject.getImportType();
+ for (IProjectExamplesWizardPage page:pages) {
+ if (projectType != null &&
projectType.equals(page.getProjectExampleType())) {
+ page.setProjectExample(selectedProject);
+ } else {
+ page.setProjectExample(null);
+ }
+ }
+ } else {
+ selectedProject = null;
+ String description = ""; //$NON-NLS-1$
+ if (selected instanceof ProjectExampleCategory) {
+ ProjectExampleCategory category = (ProjectExampleCategory) selected;
+ if (category.getDescription() != null) {
+ description = category.getDescription();
+ }
+ }
+ descriptionText.setText(description);
+ projectName.setText(""); //$NON-NLS-1$
+ projectURL.setText(""); //$NON-NLS-1$
+ projectSize.setText(""); //$NON-NLS-1$
+ requirementsPage.setProjectExample(null);
+ //readyPage.setProjectExample(null);
+ }
+ boolean canFinish = refresh(false);
+ setPageComplete(canFinish);
+ }
+
+ });
+
+ siteCombo.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ siteFilter.setSite(siteCombo.getText());
+ viewer.refresh();
+ }
+
+ });
+
+ button.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
+ store.setValue(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES,
button.getSelection());
+ refresh(viewer, true);
+ if (siteCombo != null) {
+ String[] items = getItems();
+ int index = siteCombo.getSelectionIndex();
+ siteCombo.setItems(items);
+ if (items.length > 0 && (index < 0 || index > items.length) ) {
+ siteCombo.select(0);
+ } else {
+ siteCombo.select(index);
+ }
+ }
+ siteFilter.setSite(siteCombo.getText());
+ viewer.refresh();
+ }
+
+ });
+ setPageComplete(false);
+
+ setControl(composite);
+
+ refresh(viewer, true);
+ siteCombo.setText(ProjectExamplesActivator.ALL_SITES);
+ }
+
+ private void refresh(final TreeViewer viewer, boolean show) {
+ AdaptableList input = new AdaptableList(getCategories(show));
+ viewer.setInput(input);
+ viewer.refresh();
+ String[] items = getItems();
+ siteCombo.setItems(items);
+ }
+
+ private List<ProjectExampleCategory> getCategories(boolean show) {
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) {
+ categories = ProjectExampleUtil.getProjects(monitor);
+ }
+ };
+ try {
+ new ProgressMonitorDialog(getShell()).run(true, true, op);
+ } catch (Exception e) {
+ ProjectExamplesActivator.log(e);
+ }
+ HashSet<IProjectExampleSite> invalidSites =
ProjectExampleUtil.getInvalidSites();
+ boolean showInvalidSites =
ProjectExamplesActivator.getDefault().getPreferenceStore().getBoolean(ProjectExamplesActivator.SHOW_INVALID_SITES);
+ if (invalidSites.size() > 0 && showInvalidSites && show) {
+ String message =
Messages.NewProjectExamplesWizardPage_Cannot_access_the_following_sites;
+ for (IProjectExampleSite site:invalidSites) {
+ message = message + site.getName() + "\n"; //$NON-NLS-1$
+ ProjectExamplesActivator.log(NLS.bind(Messages.InvalideSite, new Object[]
{site.getName(), site.getUrl()} ));
+ }
+ MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(getShell(),
Messages.NewProjectExamplesWizardPage_Invalid_Sites, message,
Messages.NewProjectExamplesWizardPage_Show_this_dialog_next_time, true,
ProjectExamplesActivator.getDefault().getPreferenceStore(),
ProjectExamplesActivator.SHOW_INVALID_SITES);
+ boolean toggleState = dialog.getToggleState();
+ ProjectExamplesActivator.getDefault().getPreferenceStore().setValue(ProjectExamplesActivator.SHOW_INVALID_SITES,
toggleState);
+ }
+ return categories;
+ }
+
+ private String[] getItems() {
+ //List<Category> categories = getCategories(true);
+ Set<String> sites = new TreeSet<String>();
+ sites.add(ProjectExamplesActivator.ALL_SITES);
+ for (ProjectExampleCategory category:categories) {
+ List<ProjectExample> projects = category.getProjects();
+ for (ProjectExample project:projects) {
+ String name = project.getSite() == null ? ProjectExamplesActivator.ALL_SITES :
project.getSite().getName();
+ sites.add(name);
+ }
+ }
+ String[] items = sites.toArray(new String[0]);
+ return items;
+ }
+
+ private class ProjectLabelProvider extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ return super.getImage(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof ProjectExampleCategory) {
+ ProjectExampleCategory category = (ProjectExampleCategory) element;
+ return category.getName();
+ }
+ if (element instanceof ProjectExample) {
+ ProjectExample project = (ProjectExample) element;
+ return project.getShortDescription();
+ }
+ return super.getText(element);
+ }
+ }
+
+ private class ProjectContentProvider implements ITreeContentProvider {
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof AdaptableList) {
+ Object[] childCollections = ((AdaptableList)parentElement).getChildren();
+ //List children = (List) parentElement;
+ //return children.toArray();
+ return childCollections;
+ }
+ if (parentElement instanceof ProjectExampleCategory) {
+ ProjectExampleCategory category = (ProjectExampleCategory) parentElement;
+ return category.getProjects().toArray();
+ }
+ return new Object[0];
+ }
+
+ public Object getParent(Object element) {
+ if (element instanceof ProjectExample) {
+ return ((ProjectExample)element).getCategory();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return element instanceof ProjectExampleCategory;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ }
+
+ public IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ public boolean refresh(boolean force) {
+ boolean canFinish = false;
+
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ if (object instanceof ProjectExample) {
+ // FIXME
+ canFinish=true;
+ ProjectExample project = (ProjectExample) object;
+ String importType = project.getImportType();
+ if (importType != null && importType.length() > 0) {
+ IImportProjectExample importProjectExample =
ProjectExamplesActivator.getDefault().getImportProjectExample(importType);
+ if (importProjectExample == null) {
+ // FIXME
+ canFinish = false;
+ break;
+ } else {
+ //setDefaultNote();
+ }
+ }
+ if (force || project.getUnsatisfiedFixes() == null) {
+ List<ProjectFix> fixes = project.getFixes();
+ List<ProjectFix> unsatisfiedFixes = new ArrayList<ProjectFix>();
+ project.setUnsatisfiedFixes(unsatisfiedFixes);
+ for (ProjectFix fix:fixes) {
+ if (!ProjectExamplesActivator.canFix(project, fix)) {
+ unsatisfiedFixes.add(fix);
+ }
+ }
+ }
+ if (project.getUnsatisfiedFixes().size() > 0) {
+ // FIXME
+ } else {
+
+ }
+
+ } else {
+ canFinish=false;
+ break;
+ }
+ }
+ return canFinish;
+ }
+
+ public ProjectExample getSelectedProject() {
+ return selectedProject;
+ }
+
+}
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesReadyPage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesReadyPage.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesReadyPage.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,121 @@
+package org.jboss.tools.project.examples.wizard;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jdt.internal.ui.typehierarchy.ShowQualifiedTypeNamesAction;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+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.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.model.ProjectExample;
+
+public class NewProjectExamplesReadyPage extends WizardPage {
+
+ private static final String SHOW_THE_QUICK_FIX_DIALOG = "Show the Quick Fix
dialog";
+ private static final String SHOW_README_FILE_FOR_FURTHER_INSTRUCTIONS = "Show
readme file for further instructions";
+ private Button showReadme;
+ private List<ProjectExample> projectExamples;
+ private Button showQuickFix;
+
+ public NewProjectExamplesReadyPage(List<ProjectExample> projectExamples) {
+ super("org.jboss.tools.project.examples.ready"); //$NON-NLS-1$
+ setImageDescriptor(
ProjectExamplesActivator.imageDescriptorFromPlugin(ProjectExamplesActivator.PLUGIN_ID,
"icons/new_wiz.gif")); //$NON-NLS-1$
+ this.projectExamples = projectExamples;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1,false));
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ composite.setLayoutData(gd);
+ Dialog.applyDialogFont(composite);
+ setControl(composite);
+
+ showQuickFix = new Button(composite, SWT.CHECK);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ showQuickFix.setLayoutData(gd);
+ showQuickFix.setText(SHOW_THE_QUICK_FIX_DIALOG);
+ showQuickFix.setSelection(false);
+ showQuickFix.setEnabled(false);
+
+ showReadme = new Button(composite, SWT.CHECK);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ showReadme.setLayoutData(gd);
+ showReadme.setText(SHOW_README_FILE_FOR_FURTHER_INSTRUCTIONS);
+ showReadme.setSelection(false);
+ showReadme.setEnabled(false);
+
+ if (projectExamples != null && projectExamples.size() > 0) {
+ configure(projectExamples);
+ }
+ setPageComplete(true);
+ }
+
+ public void configure(List<ProjectExample> projectExamples) {
+ ProjectExample projectExample = projectExamples.get(0);
+ if (projectExample != null) {
+ setTitle(projectExample.getShortDescription());
+ setDescription("'" + projectExample.getShortDescription() + "'
Project is now ready");
+ if (showReadme != null) {
+ if (projectExample.isWelcome()) {
+ showReadme.setEnabled(true);
+ showReadme.setSelection(true);
+ showReadme.setText("Show '" + projectExample.getWelcomeURL() +
"' for further instructions");
+ } else {
+ showReadme.setEnabled(false);
+ showReadme.setSelection(false);
+ showReadme.setText(SHOW_README_FILE_FOR_FURTHER_INSTRUCTIONS);
+ }
+ }
+ List<IMarker> markers = ProjectExamplesActivator
+ .getMarkers(projectExamples);
+ if (markers != null && markers.size() > 0) {
+ showQuickFix.setEnabled(true);
+ showQuickFix.setSelection(true);
+ }
+ }
+ }
+
+ @Override
+ public IWizardPage getPreviousPage() {
+ IWizard wizard = getWizard();
+ if (wizard instanceof NewProjectExamplesWizard2) {
+ ProjectExample projectExample = ((NewProjectExamplesWizard2) wizard)
+ .getSelectedProjectExample();
+ if (projectExample != null
+ && projectExample.getImportType() != null) {
+ List<IProjectExamplesWizardPage> pages = ((NewProjectExamplesWizard2) wizard)
+ .getContributedPages();
+ IProjectExamplesWizardPage previousPage = null;
+ for (IProjectExamplesWizardPage page : pages) {
+ if (projectExample.getImportType().equals(
+ page.getProjectExampleType())) {
+ previousPage = page;
+ }
+ }
+ if (previousPage != null) {
+ return previousPage;
+ }
+ }
+ return ((NewProjectExamplesWizard2) wizard).getLocationsPage();
+ }
+ return super.getPreviousPage();
+ }
+
+ public Button getShowReadme() {
+ return showReadme;
+ }
+
+ public Button getShowQuickFix() {
+ return showQuickFix;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,559 @@
+package org.jboss.tools.project.examples.wizard;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashSet;
+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.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.mylyn.internal.discovery.core.model.BundleDiscoveryStrategy;
+import org.eclipse.mylyn.internal.discovery.core.model.ConnectorDescriptor;
+import org.eclipse.mylyn.internal.discovery.core.model.ConnectorDiscovery;
+import org.eclipse.mylyn.internal.discovery.core.model.DiscoveryConnector;
+import org.eclipse.mylyn.internal.discovery.core.model.RemoteBundleDiscoveryStrategy;
+import org.eclipse.mylyn.internal.discovery.ui.DiscoveryUi;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+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.ui.IDownloadRuntimes;
+import org.jboss.tools.runtime.ui.RuntimeUIActivator;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+public class NewProjectExamplesRequirementsPage extends WizardPage {
+
+ private static final String PAGE_NAME =
"org.jboss.tools.project.examples.requirements"; //$NON-NLS-1$
+ private ProjectExample projectExample;
+ private Text descriptionText;
+ private Text projectSize;
+ private List<ProjectFix> fixes = new ArrayList<ProjectFix>();
+ private TableViewer tableViewer;
+ private ArrayList<ProjectFix> unsatisfiedFixes = new
ArrayList<ProjectFix>();
+ private Image checkboxOn;
+ private Image checkboxOff;
+
+ public NewProjectExamplesRequirementsPage(ProjectExample projectExample) {
+ super(PAGE_NAME);
+ this.projectExample = projectExample;
+ setTitleAndDescription(projectExample);
+ }
+
+ private void setTitleAndDescription(ProjectExample projectExample) {
+ setTitle( "Requirements" );
+ setDescription( "Project Example Requirements" );
+ if (projectExample != null) {
+ if (projectExample.getShortDescription() != null) {
+ setTitle(projectExample.getShortDescription());
+ }
+ if (projectExample.getDescription() != null) {
+ setDescription(ProjectExamplesActivator.getShortDescription(projectExample.getDescription()));
+ }
+ if (descriptionText != null) {
+ if (projectExample.getDescription() != null) {
+ descriptionText.setText(projectExample.getDescription());
+ }
+ if (projectExample.getSizeAsText() != null) {
+ projectSize.setText(projectExample.getSizeAsText());
+ }
+ }
+ } else {
+ setTitle( "Requirements" );
+ setDescription( "Project Example Requirements" );
+ if (descriptionText != null) {
+ descriptionText.setText(""); //$NON-NLS-1$
+ projectSize.setText(""); //$NON-NLS-1$
+ }
+ }
+ }
+
+ protected NewProjectExamplesRequirementsPage() {
+ super(PAGE_NAME);
+ setTitleAndDescription(null);
+ setImageDescriptor(
ProjectExamplesActivator.imageDescriptorFromPlugin(ProjectExamplesActivator.PLUGIN_ID,
"icons/new_wiz.gif")); //$NON-NLS-1$
+ checkboxOn =
RuntimeUIActivator.imageDescriptorFromPlugin(RuntimeUIActivator.PLUGIN_ID,
"/icons/xpl/complete_tsk.gif").createImage();
+ checkboxOff =
RuntimeUIActivator.imageDescriptorFromPlugin(RuntimeUIActivator.PLUGIN_ID,
"/icons/xpl/incomplete_tsk.gif").createImage();
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2,false));
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ composite.setLayoutData(gd);
+ Dialog.applyDialogFont(composite);
+
+ Label descriptionLabel = new Label(composite,SWT.NONE);
+ descriptionLabel.setText(Messages.NewProjectExamplesWizardPage_Description);
+ gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
+ gd.horizontalSpan = 2;
+ descriptionLabel.setLayoutData(gd);
+ descriptionText = new Text(composite, SWT.H_SCROLL | SWT.V_SCROLL
+ | SWT.READ_ONLY | SWT.BORDER | SWT.WRAP);
+ gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ GC gc = new GC(parent);
+ gd.heightHint = Dialog.convertHeightInCharsToPixels(gc
+ .getFontMetrics(), 6);
+ gc.dispose();
+ gd.horizontalSpan = 2;
+ gd.widthHint = 250;
+ descriptionText.setLayoutData(gd);
+
+ Label projectSizeLabel = new Label(composite,SWT.NULL);
+ projectSizeLabel.setText(Messages.NewProjectExamplesWizardPage_Project_size);
+ projectSize = new Text(composite,SWT.READ_ONLY);
+ projectSize.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label label = new Label(composite, SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.horizontalSpan = 2;
+ label.setLayoutData(gd);
+
+// label = new Label(composite, SWT.NONE);
+// gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+// gd.horizontalSpan = 2;
+// label.setLayoutData(gd);
+
+
+ Group fixesGroup = new Group(composite, SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.horizontalSpan = 2;
+ fixesGroup.setLayoutData(gd);
+ GridLayout layout = new GridLayout(2, false);
+ fixesGroup.setLayout(layout);
+ fixesGroup.setText("Requirements");
+
+ tableViewer = new TableViewer(fixesGroup, SWT.SINGLE | SWT.FULL_SELECTION |
SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.BORDER);
+ Table table = tableViewer.getTable();
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 200;
+ table.setLayoutData(gd);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ String[] columnNames = new String[] { "Type", "Description",
"Found?"};
+ int[] columnWidths = new int[] { 100, 300, 50};
+
+ for (int i = 0; i < columnNames.length; i++) {
+ TableColumn tc = new TableColumn(table, SWT.LEFT);
+ tc.setText(columnNames[i]);
+ tc.setWidth(columnWidths[i]);
+ }
+
+ tableViewer.setLabelProvider(new FixLabelProvider());
+ tableViewer.setContentProvider(new FixContentProvider(fixes));
+
+ createButtons(fixesGroup, tableViewer);
+ setPageComplete(true);
+ setControl(composite);
+ if (projectExample != null) {
+ setProjectExample(projectExample);
+ }
+
+ }
+
+ private void createButtons(Composite parent, final TableViewer viewer) {
+ Composite buttonComposite = new Composite(parent, SWT.NONE);
+ buttonComposite.setLayout(new GridLayout(1,false));
+ buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
+
+ final Button install = new Button(buttonComposite, SWT.PUSH);
+ install.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ install.setText("Install...");
+ install.setEnabled(false);
+ install.addSelectionListener(new SelectionListener(){
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ ProjectFix fix = getSelectedProjectFix();
+ if (ProjectFix.WTP_RUNTIME.equals(fix.getType())
+ || ProjectFix.SEAM_RUNTIME.equals(fix.getType())) {
+ String preferenceId =
"org.jboss.tools.runtime.preferences.RuntimePreferencePage"; //$NON-NLS-1$
+ PreferenceDialog preferenceDialog =
PreferencesUtil.createPreferenceDialogOn(getShell(), preferenceId, null, null);
+ preferenceDialog.open();
+ refreshFixes();
+ } else if (ProjectFix.PLUGIN_TYPE.equals(fix.getType())) {
+ String connectorId = fix.getProperties().get(ProjectFix.CONNECTOR_ID);
+ Set<String> connectorIds = new HashSet<String>();
+ if (connectorId != null) {
+ String[] ids = connectorId.split(","); //$NON-NLS-1$
+ for (String id:ids) {
+ if (id != null && !id.trim().isEmpty()) {
+ connectorIds.add(id.trim());
+ }
+ }
+ }
+ if (connectorIds.size() > 0) {
+ try {
+ install(connectorIds);
+ } catch (Exception e1) {
+ ProjectExamplesActivator.log(e1);
+ }
+ }
+ refreshFixes();
+ }
+
+ }
+
+ });
+
+// final Button p2install = new Button(buttonComposite, SWT.PUSH);
+// p2install.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+// p2install.setText("Install New Software...");
+// p2install.setToolTipText("P2 Install New Software");
+// p2install.addSelectionListener(new SelectionListener(){
+//
+// public void widgetDefaultSelected(SelectionEvent e) {
+//
+// }
+//
+// public void widgetSelected(SelectionEvent e) {
+// IHandlerService handlerService = (IHandlerService)
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(IHandlerService.class);
+// try {
+//
handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.install", new
Event()); //$NON-NLS-1$
+// }
+// catch (Exception e1) {
+// ProjectExamplesActivator.log(e1);
+// }
+// refreshFixes();
+// }
+//
+// });
+
+ final Button downloadAndInstall = new Button(buttonComposite, SWT.PUSH);
+ downloadAndInstall.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ downloadAndInstall.setText("Download and Install...");
+ downloadAndInstall.setEnabled(false);
+
+ downloadAndInstall.addSelectionListener(new SelectionListener(){
+
+ public void widgetSelected(SelectionEvent e) {
+ ProjectFix fix = getSelectedProjectFix();
+ if (fix != null) {
+ DownloadRuntime runtime = getDownloadRuntime(fix);
+ DownloadRuntimeDialog dialog = new DownloadRuntimeDialog(getShell(), runtime);
+ dialog.open();
+ refreshFixes();
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+// final IDownloadRuntimes downloader = getDownloader();
+// if (downloader != null) {
+// final Button downloadRuntimes = new Button(buttonComposite, SWT.PUSH);
+// downloadRuntimes.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+// downloadRuntimes.setText("Download Runtimes...");
+// downloadRuntimes.setEnabled(true);
+// downloadRuntimes.addSelectionListener(new SelectionListener() {
+//
+// public void widgetSelected(SelectionEvent e) {
+// downloader.execute(getShell());
+// }
+//
+// public void widgetDefaultSelected(SelectionEvent e) {
+//
+// }
+// });
+// }
+
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection sel = viewer.getSelection();
+ install.setEnabled(false);
+ downloadAndInstall.setEnabled(false);
+ downloadAndInstall.setToolTipText("");
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ if (object instanceof ProjectFix) {
+ ProjectFix fix = (ProjectFix) object;
+ if (!unsatisfiedFixes.contains(fix)) {
+ return;
+ }
+ if (ProjectFix.WTP_RUNTIME.equals(fix.getType())
+ || ProjectFix.SEAM_RUNTIME.equals(fix.getType())) {
+ DownloadRuntime downloadRuntime = getDownloadRuntime(fix);
+ downloadAndInstall.setEnabled(downloadRuntime != null);
+ downloadAndInstall.setToolTipText("Download and install " +
downloadRuntime.getName());
+ install.setEnabled(true);
+ install.setToolTipText("JBoss Runtime Detection");
+ } else if (ProjectFix.PLUGIN_TYPE.equals(fix.getType())) {
+ install.setEnabled(fix.getProperties().get(ProjectFix.CONNECTOR_ID) != null);
+ install.setToolTipText("Install required feature(s)");
+ }
+
+ }
+ }
+ }
+ });
+
+ }
+
+ protected ProjectFix getSelectedProjectFix() {
+ ISelection sel = tableViewer.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ if (object instanceof ProjectFix) {
+ return (ProjectFix) object;
+ }
+ }
+ return null;
+ }
+
+ private DownloadRuntime getDownloadRuntime(ProjectFix fix) {
+ final String downloadId = fix.getProperties().get(ProjectFix.DOWNLOAD_ID);
+ if (downloadId != null) {
+ return ProjectExamplesActivator.getDefault().getDownloadRuntimes().get(downloadId);
+ }
+ return null;
+ }
+
+ private IDownloadRuntimes getDownloader() {
+ Bundle bundle = Platform.getBundle(ProjectExamplesActivator.PLUGIN_ID);
+ if (bundle != null) {
+ ServiceReference<IDownloadRuntimes> reference =
bundle.getBundleContext().getServiceReference(IDownloadRuntimes.class);
+ if (reference != null) {
+ return bundle.getBundleContext().getService(reference);
+ }
+ }
+ return null;
+ }
+
+ public ProjectExample getProjectExample() {
+ return projectExample;
+ }
+
+ public void setProjectExample(ProjectExample projectExample) {
+ this.projectExample = projectExample;
+ setTitleAndDescription(projectExample);
+ refreshFixes();
+ }
+
+ protected void refreshFixes() {
+ if (getControl() == null || getControl().isDisposed()) {
+ return;
+ }
+ fixes = new ArrayList<ProjectFix>();
+ unsatisfiedFixes = new ArrayList<ProjectFix>();
+ if (projectExample == null) {
+ return;
+ }
+
+ fixes = projectExample.getFixes();
+ projectExample.setUnsatisfiedFixes(unsatisfiedFixes);
+ for (ProjectFix fix:fixes) {
+ if (!ProjectExamplesActivator.canFix(projectExample, fix)) {
+ unsatisfiedFixes.add(fix);
+ }
+ }
+ tableViewer.setInput(fixes);
+ }
+
+ private String getProjectFixDescription(ProjectFix projectFix) {
+
+ return projectFix.getProperties().get(ProjectFix.DESCRIPTION);
+ }
+
+ private Image getProjectFixImage(ProjectFix projectFix) {
+ if (ProjectFix.WTP_RUNTIME.equals(projectFix.getType())) {
+ return
ProjectExamplesActivator.getDefault().getImage("/icons/wtp_server.gif");
//$NON-NLS-1$
+ }
+ if (ProjectFix.SEAM_RUNTIME.equals(projectFix.getType())) {
+ return ProjectExamplesActivator.getDefault().getImage("/icons/seam16.png");
//$NON-NLS-1$
+ }
+ if (ProjectFix.PLUGIN_TYPE.equals(projectFix.getType())) {
+ return
ProjectExamplesActivator.getDefault().getImage("/icons/software.png");
//$NON-NLS-1$
+ }
+ return null;
+ }
+
+
+ protected void install(final Set<String> connectorIds) throws
InvocationTargetException, InterruptedException {
+ final IStatus[] results = new IStatus[1];
+ final ConnectorDiscovery[] connectorDiscoveries = new ConnectorDiscovery[1];
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
+ connectorDiscoveries[0] = new ConnectorDiscovery();
+
+ // look for descriptors from installed bundles
+ connectorDiscoveries[0].getDiscoveryStrategies().add(new BundleDiscoveryStrategy());
+
+ RemoteBundleDiscoveryStrategy remoteDiscoveryStrategy = new
RemoteBundleDiscoveryStrategy();
+ remoteDiscoveryStrategy.setDirectoryUrl(ProjectExamplesActivator.getDefault().getConfigurator().getJBossDiscoveryDirectory());
+ connectorDiscoveries[0].getDiscoveryStrategies().add(remoteDiscoveryStrategy);
+
+ connectorDiscoveries[0].setEnvironment(ProjectExamplesActivator.getEnvironment());
+ connectorDiscoveries[0].setVerifyUpdateSiteAvailability(true);
+ results[0] = connectorDiscoveries[0].performDiscovery(monitor);
+ if (monitor.isCanceled()) {
+ results[0] = Status.CANCEL_STATUS;
+ }
+ }
+ };
+ getWizard().getContainer().run(true, true, runnable);
+ if (results[0] == null) {
+ return;
+ }
+ if (results[0].isOK()) {
+ List<DiscoveryConnector> connectors = connectorDiscoveries[0].getConnectors();
+ List<ConnectorDescriptor> installableConnectors = new
ArrayList<ConnectorDescriptor>();
+ for (DiscoveryConnector connector:connectors) {
+ if (connectorIds.contains(connector.getId())) {
+ installableConnectors.add(connector);
+ }
+ }
+ DiscoveryUi.install(installableConnectors, getWizard().getContainer());
+ } else {
+ String message = results[0].toString();
+ switch (results[0].getSeverity()) {
+ case IStatus.ERROR:
+ MessageDialog.openError(getShell(), "Error", message);
+ break;
+ case IStatus.WARNING:
+ MessageDialog.openWarning(getShell(), "Warning", message);
+ break;
+ case IStatus.INFO:
+ MessageDialog.openInformation(getShell(), "Information", message);
+ break;
+ }
+ }
+ }
+
+ private class FixLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (columnIndex == 2 && element instanceof ProjectFix) {
+ ProjectFix fix = (ProjectFix) element;
+ if (!unsatisfiedFixes.contains(fix)) {
+ return checkboxOn;
+ } else {
+ return checkboxOff;
+ }
+
+ }
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof ProjectFix) {
+ ProjectFix fix = (ProjectFix) element;
+ if (columnIndex == 0) {
+ if (ProjectFix.WTP_RUNTIME.equals(fix.getType())) {
+ return "server/runtime";
+ }
+ return fix.getType();
+ }
+ if (columnIndex == 1) {
+ return getProjectFixDescription(fix);
+ }
+
+ }
+ return null;
+ }
+ }
+
+ private class FixContentProvider implements IStructuredContentProvider {
+
+ private List<ProjectFix> fixes;
+
+ public FixContentProvider(List<ProjectFix> fixes) {
+ this.fixes = fixes;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return fixes.toArray();
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ fixes = (List<ProjectFix>) newInput;
+ }
+
+ }
+
+ @Override
+ public IWizardPage getNextPage() {
+ // FIXME
+ if (projectExample != null &&
ProjectExamplesActivator.MAVEN_ARCHETYPE.equals(projectExample.getImportType())) {
+ IWizard wizard = getWizard();
+ if (wizard instanceof NewProjectExamplesWizard2) {
+ ProjectExample projectExample =
((NewProjectExamplesWizard2)wizard).getSelectedProjectExample();
+ if (projectExample != null && projectExample.getImportType() != null) {
+ List<IProjectExamplesWizardPage> pages =
((NewProjectExamplesWizard2)wizard).getContributedPages();
+ for (IProjectExamplesWizardPage page:pages) {
+ if (projectExample.getImportType().equals(page.getProjectExampleType())) {
+ return page;
+ }
+ }
+ }
+ return ((NewProjectExamplesWizard2)wizard).getLocationsPage();
+ }
+ }
+ return super.getNextPage();
+ }
+
+ @Override
+ public void dispose() {
+ if (checkboxOff != null) {
+ checkboxOff.dispose();
+ }
+ if (checkboxOn != null) {
+ checkboxOn.dispose();
+ }
+ super.dispose();
+ }
+}
Deleted:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -1,84 +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.wizard;
-
-/**
- * @author snjeza
- *
- */
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.jboss.tools.project.examples.Messages;
-import org.jboss.tools.project.examples.ProjectExamplesActivator;
-import org.jboss.tools.project.examples.model.ProjectExample;
-
-public class NewProjectExamplesWizard extends Wizard implements INewWizard {
-
- private List<ProjectExample> projects = new ArrayList<ProjectExample>();
-
- private NewProjectExamplesWizardPage page;
-
- public NewProjectExamplesWizard() {
- super();
- setWindowTitle(Messages.NewProjectExamplesWizard_New_Project_Example);
-
- }
-
- /**
- * Creates an empty wizard for creating a new resource in the workspace.
- */
-
- @Override
- public boolean performFinish() {
- final List<ProjectExample> selectedProjects = new
ArrayList<ProjectExample>();
- if (page.getSelection() == null || page.getSelection().size() <= 0) {
- return false;
- }
- IStructuredSelection selection = page.getSelection();
- Iterator iterator = selection.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object instanceof ProjectExample) {
- ProjectExample project = (ProjectExample) object;
- selectedProjects.add(project);
- }
- }
- ProjectExamplesActivator.importProjectExamples(selectedProjects, page.showQuickFix());
- return true;
- }
-
-
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- initializeDefaultPageImageDescriptor();
- }
-
- protected void initializeDefaultPageImageDescriptor() {
- ImageDescriptor desc = ProjectExamplesActivator
- .imageDescriptorFromPlugin(ProjectExamplesActivator.PLUGIN_ID,
- "icons/new_wiz.gif"); //$NON-NLS-1$
- setDefaultPageImageDescriptor(desc);
- }
-
- @Override
- public void addPages() {
- super.addPages();
- page = new NewProjectExamplesWizardPage();
- addPage(page);
- }
-
-}
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,252 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2012 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.wizard;
+
+/**
+ * @author snjeza
+ *
+ */
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.project.examples.Messages;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.dialog.xpl.QuickFixPage;
+import org.jboss.tools.project.examples.model.ProjectExample;
+
+public class NewProjectExamplesWizard2 extends Wizard implements INewWizard {
+
+ private NewProjectExamplesMainPage mainPage;
+ private NewProjectExamplesRequirementsPage requirementsPage;
+ private NewProjectExamplesLocationPage locationPage;
+ private IStructuredSelection fSelection;
+ //private NewProjectExamplesReadyPage readyPage;
+ List<IProjectExamplesWizardPage> contributedPages = new
LinkedList<IProjectExamplesWizardPage>();
+ private ProjectExample projectExample;
+ private boolean isCentral = false;
+ //private QuickFixPage quickFixPage;
+
+ public NewProjectExamplesWizard2() {
+ super();
+ setWindowTitle(Messages.NewProjectExamplesWizard_New_Project_Example);
+ setNeedsProgressMonitor(true);
+ }
+
+ public NewProjectExamplesWizard2(ProjectExample projectExample) {
+ super();
+ this.projectExample = projectExample;
+ this.isCentral = true;
+ setWindowTitle(Messages.NewProjectExamplesWizard_New_Project_Example);
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * Creates an empty wizard for creating a new resource in the workspace.
+ */
+
+ @Override
+ public boolean performFinish() {
+ final List<ProjectExample> selectedProjects = new
ArrayList<ProjectExample>();
+ IWorkingSet[] workingSets = new IWorkingSet[0];
+ Map<String, Object> propertiesMap = new HashMap<String, Object>();
+ if (mainPage != null) {
+ if (mainPage.getSelection() == null || mainPage.getSelection().size() <= 0) {
+ return false;
+ }
+ IStructuredSelection selection = mainPage.getSelection();
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ if (object instanceof ProjectExample) {
+ ProjectExample project = (ProjectExample) object;
+ selectedProjects.add(project);
+ }
+ }
+ } else {
+ if (projectExample == null) {
+ return false;
+ }
+ selectedProjects.add(projectExample);
+
+ }
+ if (selectedProjects.size() > 0) {
+ projectExample = selectedProjects.get(0);
+ }
+ if (projectExample != null) {
+ if (!ProjectExamplesActivator.MAVEN_ARCHETYPE.equals(projectExample.getImportType()))
{
+ workingSets = locationPage.getWorkingSets();
+ } else {
+ // FIXME
+ }
+ for (IProjectExamplesWizardPage contributedPage:contributedPages) {
+ if (!contributedPage.finishPage()) {
+ return false;
+ }
+ Map<String, Object> pMap = contributedPage.getPropertiesMap();
+ if (pMap != null) {
+ propertiesMap.putAll(pMap);
+ }
+ }
+ }
+ ProjectExamplesActivator.importProjectExamples(selectedProjects, workingSets,
propertiesMap);
+ return true;
+ }
+
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ initializeDefaultPageImageDescriptor();
+ }
+
+ protected void initializeDefaultPageImageDescriptor() {
+ ImageDescriptor desc = ProjectExamplesActivator
+ .imageDescriptorFromPlugin(ProjectExamplesActivator.PLUGIN_ID,
+ "icons/new_wiz.gif"); //$NON-NLS-1$
+ setDefaultPageImageDescriptor(desc);
+ }
+
+ @Override
+ public void addPages() {
+ createContributedPages();
+ requirementsPage = new NewProjectExamplesRequirementsPage();
+ //readyPage = new NewProjectExamplesReadyPage();
+ if (projectExample == null) {
+ mainPage = new NewProjectExamplesMainPage(requirementsPage, contributedPages);
+ addPage(mainPage);
+ } else {
+ requirementsPage.setProjectExample(projectExample);
+ //readyPage.setProjectExample(projectExample);
+ }
+ addPage(requirementsPage);
+ locationPage = new NewProjectExamplesLocationPage();
+ addPage(locationPage);
+ if (getSelection() != null) {
+ locationPage.init(getSelection(), getActivePart());
+ }
+ // contributed page
+ for(IProjectExamplesWizardPage page:contributedPages) {
+ addPage(page);
+ }
+ //addPage(readyPage);
+ //quickFixPage = new QuickFixPage("Quick Fix Descripton", new
LinkedHashMap());
+ //addPage(quickFixPage);
+ }
+
+ protected void createContributedPages() {
+ Map<String, List<ContributedPage>> extensionPages =
ProjectExamplesActivator.getDefault().getContributedPages();
+ Set<String> keySet = extensionPages.keySet();
+ for (String key:keySet) {
+ List<ContributedPage> contributions = extensionPages.get(key);
+ for(ContributedPage page:contributions) {
+ try {
+ if (!isCentral) {
+ IProjectExamplesWizardPage contributedPage = (IProjectExamplesWizardPage)
page.getConfigurationElement().createExecutableExtension(ProjectExamplesActivator.CLASS);
+ contributedPages.add(contributedPage);
+ } else {
+ if (projectExample != null && key.equals(projectExample.getImportType()))
{
+ IProjectExamplesWizardPage contributedPage = (IProjectExamplesWizardPage)
page.getConfigurationElement().createExecutableExtension(ProjectExamplesActivator.CLASS);
+ contributedPage.setProjectExample(projectExample);
+ contributedPages.add(contributedPage);
+ }
+ }
+ } catch (CoreException e) {
+ ProjectExamplesActivator.log(e);
+ }
+ }
+ }
+ }
+
+ private IWorkbenchPart getActivePart() {
+ IWorkbenchWindow activeWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (activeWindow != null) {
+ IWorkbenchPage activePage= activeWindow.getActivePage();
+ if (activePage != null) {
+ return activePage.getActivePart();
+ }
+ }
+ return null;
+ }
+
+ private IStructuredSelection getSelection() {
+ if (fSelection == null) {
+ ISelection sel = getActivePart().getSite().getSelectionProvider()
+ .getSelection();
+ if (sel instanceof IStructuredSelection) {
+ fSelection = (IStructuredSelection) sel;
+ }
+ }
+ return fSelection;
+ }
+
+ public ProjectExample getSelectedProjectExample() {
+ if (projectExample != null) {
+ return projectExample;
+ }
+ return mainPage.getSelectedProject();
+ }
+
+// public IWizardPage getReadyPage() {
+// return readyPage;
+// }
+
+ public List<IProjectExamplesWizardPage> getContributedPages() {
+ return contributedPages;
+ }
+
+ public IWizardPage getLocationsPage() {
+ return locationPage;
+ }
+
+ public IWizardPage getRequirementsPage() {
+ return requirementsPage;
+ }
+
+
+ @Override
+ public boolean canFinish() {
+ ProjectExample example = getSelectedProjectExample();
+ if (example == null) {
+ return false;
+ }
+ IWizardPage[] pages = getPages();
+ for (IWizardPage page:pages) {
+ if (page instanceof IProjectExamplesWizardPage) {
+ String type = ((IProjectExamplesWizardPage) page).getProjectExampleType();
+ if (type != null && type.equals(example.getImportType())) {
+ if (!page.isPageComplete()) {
+ return false;
+ }
+ }
+ } else if (!page.isPageComplete()) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
Deleted:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -1,597 +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.wizard;
-
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-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.Monitor;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.dialogs.FilteredTree;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.model.AdaptableList;
-import org.eclipse.ui.part.PageBook;
-import org.jboss.tools.project.examples.Messages;
-import org.jboss.tools.project.examples.ProjectExamplesActivator;
-import org.jboss.tools.project.examples.dialog.FixDialog;
-import org.jboss.tools.project.examples.model.ProjectExampleCategory;
-import org.jboss.tools.project.examples.model.IImportProjectExample;
-import org.jboss.tools.project.examples.model.IProjectExampleSite;
-import org.jboss.tools.project.examples.model.ProjectExample;
-import org.jboss.tools.project.examples.model.ProjectFix;
-import org.jboss.tools.project.examples.model.ProjectExampleUtil;
-import org.jboss.tools.project.examples.preferences.ProjectExamplesPreferencePage;
-
-/**
- * @author snjeza
- *
- */
-public class NewProjectExamplesWizardPage extends WizardPage {
-
- private static final int DEFAULT_HEIGHT = 430;
- private static final int DEFAULT_WIDTH = 600;
- private IStructuredSelection selection;
- private Button showQuickFixButton;
- private Combo siteCombo;
- private Text noteText;
- private Button details;
- private PageBook notesPageBook;
- private Composite noteEmptyComposite;
- private Composite noteComposite;
- private List<ProjectExampleCategory> categories;
- private Text descriptionText;
-
-
- public NewProjectExamplesWizardPage() {
- super("org.jboss.tools.project.examples"); //$NON-NLS-1$
- setTitle( Messages.NewProjectExamplesWizardPage_Project_Example );
- setDescription( Messages.NewProjectExamplesWizardPage_Import_Project_Example );
- setImageDescriptor(
ProjectExamplesActivator.imageDescriptorFromPlugin(ProjectExamplesActivator.PLUGIN_ID,
"icons/new_wiz.gif")); //$NON-NLS-1$
- }
-
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent,SWT.NONE);
- composite.setLayout(new GridLayout(1,false));
- GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
- composite.setLayoutData(gd);
-
- Composite siteComposite = new Composite(composite,SWT.NONE);
- GridLayout gridLayout = new GridLayout(2,false);
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- siteComposite.setLayout(gridLayout);
- gd = new GridData(SWT.FILL, SWT.BEGINNING, false, false);
- siteComposite.setLayoutData(gd);
-
- final Button button = new Button(siteComposite,SWT.CHECK);
- gd = new GridData(SWT.FILL, SWT.BEGINNING, false, false);
- //gd.horizontalSpan = 2;
- button.setLayoutData(gd);
- button.setText(Messages.ProjectExamplesPreferencePage_Show_experimental_sites);
- final IPreferenceStore store =
ProjectExamplesActivator.getDefault().getPreferenceStore();
- button.setSelection(store.getBoolean(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES));
-
- Link prefLink = new Link(siteComposite, SWT.NONE);
- gd = new GridData(SWT.END, SWT.BEGINNING, false, false);
- //gd.horizontalSpan = 2;
- prefLink.setLayoutData(gd);
- prefLink.setText(Messages.NewProjectExamplesWizardPage_Project_Examples_Preferences);
- prefLink.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferenceDialog dialog =
PreferencesUtil.createPreferenceDialogOn(getShell(),ProjectExamplesPreferencePage.ID,
null, null);
- dialog.open();
- }
- });
-
- new Label(siteComposite,SWT.NONE).setText(Messages.NewProjectExamplesWizardPage_Site);
- siteCombo = new Combo(siteComposite,SWT.READ_ONLY);
- siteCombo.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
-
- new Label(composite,SWT.NONE).setText(Messages.NewProjectExamplesWizardPage_Projects);
-
- final ProjectExamplesPatternFilter filter = new ProjectExamplesPatternFilter();
-
- int styleBits = SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP;
- final FilteredTree filteredTree = new FilteredTree(composite, styleBits, filter,true);
- filteredTree.setBackground(parent.getDisplay().getSystemColor(
- SWT.COLOR_WIDGET_BACKGROUND));
- final TreeViewer viewer = filteredTree.getViewer();
- Tree tree = viewer.getTree();
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- GC gc = new GC(parent);
- gd.heightHint = Dialog.convertHeightInCharsToPixels(gc
- .getFontMetrics(), 7);
- gc.dispose();
- tree.setLayoutData(gd);
- tree.setFont(parent.getFont());
-
- viewer.setLabelProvider(new ProjectLabelProvider());
- viewer.setContentProvider(new ProjectContentProvider());
-
- final SiteFilter siteFilter = new SiteFilter();
- viewer.addFilter(siteFilter);
-
- Label descriptionLabel = new Label(composite,SWT.NONE);
- descriptionLabel.setText(Messages.NewProjectExamplesWizardPage_Description);
- descriptionText = new Text(composite,SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.READ_ONLY | SWT.BORDER | SWT.WRAP);
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gc = new GC(parent);
- gd.heightHint = Dialog.convertHeightInCharsToPixels(gc
- .getFontMetrics(), 8);
- gc.dispose();
- descriptionText.setLayoutData(gd);
-
- Composite internal = new Composite(composite, SWT.NULL);
- internal.setLayout(new GridLayout(2,false));
- gd = new GridData(GridData.FILL, GridData.FILL, true, false);
- gd.widthHint = DEFAULT_WIDTH;
- internal.setLayoutData(gd);
-
- Label projectNameLabel = new Label(internal,SWT.NULL);
- projectNameLabel.setText(Messages.NewProjectExamplesWizardPage_Project_name);
- final Text projectName = new Text(internal,SWT.BORDER | SWT.READ_ONLY);
- projectName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label projectSizeLabel = new Label(internal,SWT.NULL);
- projectSizeLabel.setText(Messages.NewProjectExamplesWizardPage_Project_size);
- final Text projectSize = new Text(internal,SWT.BORDER | SWT.READ_ONLY);
- projectSize.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label projectURLLabel = new Label(internal,SWT.NULL);
- projectURLLabel.setText(Messages.NewProjectExamplesWizardPage_URL);
- final Text projectURL = new Text(internal,SWT.BORDER | SWT.READ_ONLY);
- projectURL.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- selection = (IStructuredSelection) event.getSelection();
- Object selected = selection.getFirstElement();
- if (selected instanceof ProjectExample && selection.size() == 1) {
- ProjectExample selectedProject = (ProjectExample) selected;
- descriptionText.setText(selectedProject.getDescription());
- projectName.setText(selectedProject.getName());
- projectURL.setText(selectedProject.getUrl());
- projectSize.setText(selectedProject.getSizeAsText());
- } else {
- //Project selectedProject=null;
- descriptionText.setText(""); //$NON-NLS-1$
- projectName.setText(""); //$NON-NLS-1$
- projectURL.setText(""); //$NON-NLS-1$
- projectSize.setText(""); //$NON-NLS-1$
- }
- boolean canFinish = refresh(false);
- setPageComplete(canFinish);
- }
-
- });
-
- notesPageBook = new PageBook( internal , SWT.NONE );
- notesPageBook.setLayout(new GridLayout(1,false));
- gd=new GridData(GridData.FILL, GridData.FILL, true, false);
- gc = new GC(parent);
- gd.heightHint = Dialog.convertHeightInCharsToPixels(gc
- .getFontMetrics(), 6);
- gc.dispose();
- gd.horizontalSpan=2;
- notesPageBook.setLayoutData( gd );
-
- noteEmptyComposite = new Composite( notesPageBook, SWT.NONE );
- noteEmptyComposite.setLayout( new GridLayout(1, false));
- //notesEmptyComposite.setVisible( false );
- gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- noteEmptyComposite.setLayoutData(gd);
-
- noteComposite = new Composite(notesPageBook, SWT.NONE);
- noteComposite.setLayout(new GridLayout(2,false));
- gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- noteComposite.setLayoutData(gd);
- noteComposite.setVisible(false);
-
- notesPageBook.showPage(noteEmptyComposite);
-
- Composite messageComposite = new Composite(noteComposite, SWT.BORDER);
- messageComposite.setLayout(new GridLayout(2, false));
- gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- messageComposite.setLayoutData(gd);
-
- Label noteLabel = new Label(messageComposite,SWT.NONE);
- gd=new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
- noteLabel.setLayoutData(gd);
- Image image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
- image.setBackground(noteLabel.getBackground());
- noteLabel.setImage(image);
-
- noteText = new Text(messageComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP |
SWT.READ_ONLY);
- gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- gc = new GC(parent);
- gd.heightHint = Dialog.convertHeightInCharsToPixels(gc
- .getFontMetrics(), 3);
- gc.dispose();
- noteText.setLayoutData(gd);
-
- details = new Button(noteComposite, SWT.PUSH);
- details.setText(Messages.NewProjectExamplesWizardPage_Details);
- gd=new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
- details.setLayoutData(gd);
- details.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- Dialog dialog = new FixDialog(getShell(), NewProjectExamplesWizardPage.this);
- dialog.open();
- }
- });
- setDefaultNote();
- showQuickFixButton = new Button(composite,SWT.CHECK);
- showQuickFixButton.setText(Messages.NewProjectExamplesWizardPage_Show_the_Quick_Fix_dialog);
- showQuickFixButton.setSelection(true);
- gd=new GridData(SWT.BEGINNING, SWT.BOTTOM, false, false);
- gd.horizontalSpan=2;
- showQuickFixButton.setLayoutData(gd);
-
- siteCombo.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- siteFilter.setSite(siteCombo.getText());
- viewer.refresh();
- }
-
- });
-
- button.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
- store.setValue(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES,
button.getSelection());
- refresh(viewer, true);
- if (siteCombo != null) {
- String[] items = getItems();
- int index = siteCombo.getSelectionIndex();
- siteCombo.setItems(items);
- if (items.length > 0 && (index < 0 || index > items.length) ) {
- siteCombo.select(0);
- } else {
- siteCombo.select(index);
- }
- }
- siteFilter.setSite(siteCombo.getText());
- viewer.refresh();
- }
-
- });
- setPageComplete(false);
-
- setControl(composite);
-
- configureSizeAndLocation();
- refresh(viewer, true);
- siteCombo.setText(ProjectExamplesActivator.ALL_SITES);
- }
-
-
- private void configureSizeAndLocation() {
- Shell shell = getContainer().getShell();
- Point size = new Point(DEFAULT_WIDTH, getHeight());
- shell.setSize(size);
- Point location = getInitialLocation(size, shell);
- shell.setBounds(getConstrainedShellBounds(new Rectangle(location.x,
- location.y, size.x, size.y)));
- }
-
- private int getHeight() {
- GC gc = new GC(getControl());
- int height = Dialog.convertVerticalDLUsToPixels(gc
- .getFontMetrics(), DEFAULT_HEIGHT);
- gc.dispose();
- return height;
- }
-
- private Rectangle getConstrainedShellBounds(Rectangle preferredSize) {
- Rectangle result = new Rectangle(preferredSize.x, preferredSize.y,
- preferredSize.width, preferredSize.height);
-
- Monitor mon = getClosestMonitor(getShell().getDisplay(), Geometry
- .centerPoint(result));
-
- Rectangle bounds = mon.getClientArea();
-
- if (result.height > bounds.height) {
- result.height = bounds.height;
- }
-
- if (result.width > bounds.width) {
- result.width = bounds.width;
- }
-
- result.x = Math.max(bounds.x, Math.min(result.x, bounds.x
- + bounds.width - result.width));
- result.y = Math.max(bounds.y, Math.min(result.y, bounds.y
- + bounds.height - result.height));
-
- return result;
- }
-
- private static Monitor getClosestMonitor(Display toSearch, Point toFind) {
- int closest = Integer.MAX_VALUE;
-
- Monitor[] monitors = toSearch.getMonitors();
- Monitor result = monitors[0];
-
- for (int idx = 0; idx < monitors.length; idx++) {
- Monitor current = monitors[idx];
-
- Rectangle clientArea = current.getClientArea();
-
- if (clientArea.contains(toFind)) {
- return current;
- }
-
- int distance = Geometry.distanceSquared(Geometry
- .centerPoint(clientArea), toFind);
- if (distance < closest) {
- closest = distance;
- result = current;
- }
- }
-
- return result;
- }
-
-
- private Point getInitialLocation(Point initialSize, Shell shell) {
- Composite parent = shell.getParent();
-
- Monitor monitor = shell.getDisplay().getPrimaryMonitor();
- if (parent != null) {
- monitor = parent.getMonitor();
- }
-
- Rectangle monitorBounds = monitor.getClientArea();
- Point centerPoint;
- if (parent != null) {
- centerPoint = Geometry.centerPoint(parent.getBounds());
- } else {
- centerPoint = Geometry.centerPoint(monitorBounds);
- }
-
- return new Point(centerPoint.x - (initialSize.x / 2), Math.max(
- monitorBounds.y, Math.min(centerPoint.y
- - (initialSize.y * 2 / 3), monitorBounds.y
- + monitorBounds.height - initialSize.y)));
- }
-
- private void refresh(final TreeViewer viewer, boolean show) {
- AdaptableList input = new AdaptableList(getCategories(show));
- viewer.setInput(input);
- viewer.refresh();
- String[] items = getItems();
- siteCombo.setItems(items);
- }
-
- private List<ProjectExampleCategory> getCategories(boolean show) {
- IRunnableWithProgress op = new IRunnableWithProgress() {
-
- public void run(IProgressMonitor monitor) {
- categories = ProjectExampleUtil.getProjects(monitor);
- }
- };
- try {
- new ProgressMonitorDialog(getShell()).run(true, true, op);
- } catch (Exception e) {
- ProjectExamplesActivator.log(e);
- }
- HashSet<IProjectExampleSite> invalidSites =
ProjectExampleUtil.getInvalidSites();
- boolean showInvalidSites =
ProjectExamplesActivator.getDefault().getPreferenceStore().getBoolean(ProjectExamplesActivator.SHOW_INVALID_SITES);
- if (invalidSites.size() > 0 && showInvalidSites && show) {
- String message =
Messages.NewProjectExamplesWizardPage_Cannot_access_the_following_sites;
- for (IProjectExampleSite site:invalidSites) {
- message = message + site.getName() + "\n"; //$NON-NLS-1$
- ProjectExamplesActivator.log(NLS.bind(Messages.InvalideSite, new Object[]
{site.getName(), site.getUrl()} ));
- }
- MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(getShell(),
Messages.NewProjectExamplesWizardPage_Invalid_Sites, message,
Messages.NewProjectExamplesWizardPage_Show_this_dialog_next_time, true,
ProjectExamplesActivator.getDefault().getPreferenceStore(),
ProjectExamplesActivator.SHOW_INVALID_SITES);
- boolean toggleState = dialog.getToggleState();
- ProjectExamplesActivator.getDefault().getPreferenceStore().setValue(ProjectExamplesActivator.SHOW_INVALID_SITES,
toggleState);
- }
- return categories;
- }
-
- private String[] getItems() {
- //List<Category> categories = getCategories(true);
- Set<String> sites = new TreeSet<String>();
- sites.add(ProjectExamplesActivator.ALL_SITES);
- for (ProjectExampleCategory category:categories) {
- List<ProjectExample> projects = category.getProjects();
- for (ProjectExample project:projects) {
- String name = project.getSite() == null ? ProjectExamplesActivator.ALL_SITES :
project.getSite().getName();
- sites.add(name);
- }
- }
- String[] items = sites.toArray(new String[0]);
- return items;
- }
-
- private class ProjectLabelProvider extends LabelProvider {
-
- @Override
- public Image getImage(Object element) {
- return super.getImage(element);
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof ProjectExampleCategory) {
- ProjectExampleCategory category = (ProjectExampleCategory) element;
- return category.getName();
- }
- if (element instanceof ProjectExample) {
- ProjectExample project = (ProjectExample) element;
- return project.getShortDescription();
- }
- return super.getText(element);
- }
- }
-
- private class ProjectContentProvider implements ITreeContentProvider {
-
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof AdaptableList) {
- Object[] childCollections = ((AdaptableList)parentElement).getChildren();
- //List children = (List) parentElement;
- //return children.toArray();
- return childCollections;
- }
- if (parentElement instanceof ProjectExampleCategory) {
- ProjectExampleCategory category = (ProjectExampleCategory) parentElement;
- return category.getProjects().toArray();
- }
- return new Object[0];
- }
-
- public Object getParent(Object element) {
- if (element instanceof ProjectExample) {
- return ((ProjectExample)element).getCategory();
- }
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return element instanceof ProjectExampleCategory;
- }
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- }
-
- public IStructuredSelection getSelection() {
- return selection;
- }
-
- public boolean showQuickFix() {
- if (showQuickFixButton != null) {
- return showQuickFixButton.getSelection();
- }
- return false;
- }
-
- public boolean refresh(boolean force) {
- boolean canFinish = false;
- notesPageBook.showPage(noteEmptyComposite);
- noteComposite.setVisible(false);
- noteEmptyComposite.setVisible(true);
- Iterator iterator = selection.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object instanceof ProjectExample) {
- canFinish=true;
- ProjectExample project = (ProjectExample) object;
- String importType = project.getImportType();
- if (importType != null && importType.length() > 0) {
- IImportProjectExample importProjectExample =
ProjectExamplesActivator.getDefault().getImportProjectExample(importType);
- if (importProjectExample == null) {
- notesPageBook.showPage(noteComposite);
- noteComposite.setVisible(true);
- noteEmptyComposite.setVisible(false);
- noteText.setText(project.getImportTypeDescription());
- details.setEnabled(false);
- canFinish = false;
- break;
- } else {
- setDefaultNote();
- }
- }
- if (force || project.getUnsatisfiedFixes() == null) {
- List<ProjectFix> fixes = project.getFixes();
- List<ProjectFix> unsatisfiedFixes = new ArrayList<ProjectFix>();
- project.setUnsatisfiedFixes(unsatisfiedFixes);
- for (ProjectFix fix:fixes) {
- if (!ProjectExamplesActivator.canFix(project, fix)) {
- unsatisfiedFixes.add(fix);
- }
- }
- }
- if (project.getUnsatisfiedFixes().size() > 0) {
- notesPageBook.showPage(noteComposite);
- noteComposite.setVisible(true);
- noteEmptyComposite.setVisible(false);
- } else {
- notesPageBook.showPage(noteEmptyComposite);
- noteComposite.setVisible(false);
- noteEmptyComposite.setVisible(true);
- }
-
- } else {
- canFinish=false;
- break;
- }
- }
- return canFinish;
- }
-
- private void setDefaultNote() {
- noteText.setText(Messages.NewProjectExamplesWizardPage_Note);
- details.setEnabled(true);
- }
-
-}
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ProjectReadyWizard.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ProjectReadyWizard.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/ProjectReadyWizard.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -0,0 +1,73 @@
+/*************************************************************************************
+ * 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.wizard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.internal.ui.typehierarchy.ShowQualifiedTypeNamesAction;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages;
+import org.jboss.tools.project.examples.Messages;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.dialog.MarkerDialog;
+import org.jboss.tools.project.examples.model.ProjectExample;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class ProjectReadyWizard extends Wizard {
+
+ private List<ProjectExample> projectExamples;
+ private NewProjectExamplesReadyPage readyPage;
+
+ public ProjectReadyWizard(List<ProjectExample> projectExamples) {
+ this.projectExamples = projectExamples;
+ setDefaultPageImageDescriptor(IDEInternalWorkbenchImages
+ .getImageDescriptor(IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG));
+ setWindowTitle(Messages.NewProjectExamplesWizard_New_Project_Example);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages() {
+ super.addPages();
+ readyPage = new NewProjectExamplesReadyPage(projectExamples);
+ addPage(readyPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ boolean openWelcome = readyPage.getShowReadme().isEnabled() &&
readyPage.getShowReadme().getSelection();
+ if (openWelcome) {
+ ProjectExamplesActivator.openWelcome(projectExamples);
+ }
+ boolean showQuickFix = readyPage.getShowQuickFix().isEnabled() &&
readyPage.getShowQuickFix().getSelection();
+ if (showQuickFix) {
+ Dialog dialog = new MarkerDialog(getShell(), projectExamples);
+ dialog.open();
+ }
+ return true;
+ }
+
+}
+
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -14,10 +14,10 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -97,7 +97,7 @@
setName(Messages.NewProjectExamplesWizard_Importing);
try {
IImportProjectExample importProjectExample =
ProjectExamplesActivator.getDefault().getImportProjectExample(project.getImportType());
- if (importProjectExample.importProject(project, file, monitor)) {
+ if (importProjectExample.importProject(project, file, new HashMap<String,
Object>(), monitor)) {
importProjectExample.fix(project, monitor);
}
} catch (Exception e) {
@@ -132,11 +132,7 @@
}
List<ProjectExample> projects = new ArrayList<ProjectExample>();
projects.add(project);
- List<IMarker> markers = ProjectExamplesActivator
- .getMarkers(projects);
- if (markers != null && markers.size() > 0) {
- ProjectExamplesActivator.showQuickFix(projects);
- }
+ ProjectExamplesActivator.showReadyWizard(projects);
}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/RunProjectExample.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/RunProjectExample.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/RunProjectExample.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -71,7 +71,7 @@
if (project != null) {
List<ProjectExample> selectedProjects = new ArrayList<ProjectExample>();
selectedProjects.add(project);
- ProjectExamplesActivator.importProjectExamples(selectedProjects, true);
+ ProjectExamplesActivator.importProjectExamples(selectedProjects, null, null);
}
}
Modified:
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectTest.java
===================================================================
---
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectTest.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/examples/tests/org.jboss.tools.project.examples.test/src/org/jboss/tools/project/examples/test/ProjectTest.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -168,7 +168,7 @@
url, name, ".zip", monitor); //$NON-NLS-1$
assertNotNull(file);
IImportProjectExample importProjectExample =
ProjectExamplesActivator.getDefault().getImportProjectExample(projectExample.getImportType());
- if (importProjectExample.importProject(projectExample, file, monitor)) {
+ if (importProjectExample.importProject(projectExample, file, null, monitor)) {
importProjectExample.fix(projectExample, monitor);
}
}
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml 2012-02-15
22:20:03 UTC (rev 38783)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/plugin.xml 2012-02-15
22:40:09 UTC (rev 38784)
@@ -18,5 +18,23 @@
type="mavenArchetype">
</importProjectExample>
</extension>
+ <extension
+ point="org.jboss.tools.project.examples.wizardpages">
+ <page
+
class="org.jboss.tools.maven.project.examples.wizard.ArchetypeExamplesWizardFirstPage"
+
id="org.jboss.tools.maven.project.examples.wizard.ArchetypeExamplesWizardFirstPage"
+ name="Maven Archetype First Page"
+ priority="1"
+ type="mavenArchetype">
+ </page>
+ <page
+
class="org.jboss.tools.maven.project.examples.wizard.ArchetypeExamplesWizardPage"
+
id="org.jboss.tools.maven.project.examples.wizard.ArchetypeExamplesWizardPage"
+ name="Maven Archetype Second Page"
+ priority="2"
+ type="mavenArchetype">
+ </page>
+ </extension>
+
</plugin>
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExample.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExample.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExample.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -17,13 +17,12 @@
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.MavenModelManager;
import org.eclipse.m2e.core.project.LocalProjectScanner;
@@ -31,7 +30,7 @@
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-import org.jboss.tools.maven.project.examples.wizard.ArchetypeExamplesWizard;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
import org.jboss.tools.project.examples.model.AbstractImportProjectExample;
import org.jboss.tools.project.examples.model.ProjectExample;
@@ -43,71 +42,54 @@
AbstractImportProjectExample {
@Override
- public boolean importProject(final ProjectExample projectDescription, File file,
- final IProgressMonitor monitor) throws Exception {
+ public boolean importProject(final ProjectExample projectDescription, File file,
+ Map<String, Object> propertiesMap, final IProgressMonitor monitor) throws
Exception {
List<ProjectExample> projects = new ArrayList<ProjectExample>();
projects.add(projectDescription);
- //IPath location = getLocation();
- //final File destination = new File(location.toOSString());
-
- final boolean[] ret = new boolean[1];
- ret[0] = true;
- Display.getDefault().syncExec(new Runnable() {
-
- @Override
- public void run() {
- ArchetypeExamplesWizard wizard = new ArchetypeExamplesWizard(projectDescription);
- WizardDialog wizardDialog = new WizardDialog(getActiveShell(), wizard);
- int ok = wizardDialog.open();
- if (ok != Window.OK) {
- ret[0] = false;
- return;
- }
- List<String> includedProjects = projectDescription.getIncludedProjects();
- if (includedProjects == null) {
- includedProjects = new ArrayList<String>();
- projectDescription.setIncludedProjects(includedProjects);
- }
- projectDescription.getIncludedProjects().clear();
- String projectName = wizard.getProjectName();
- includedProjects.add(projectName);
- String artifactId = wizard.getArtifactId();
- IPath location = wizard.getLocationPath();
- String projectFolder = location.append(artifactId).toFile()
+// ArchetypeExamplesWizard wizard = new ArchetypeExamplesWizard(projectDescription);
+// WizardDialog wizardDialog = new WizardDialog(getActiveShell(), wizard);
+// int ok = wizardDialog.open();
+// if (ok != Window.OK) {
+// return false;
+// }
+ List<String> includedProjects = projectDescription.getIncludedProjects();
+ if (includedProjects == null) {
+ includedProjects = new ArrayList<String>();
+ projectDescription.setIncludedProjects(includedProjects);
+ }
+ projectDescription.getIncludedProjects().clear();
+ String projectName = (String)
propertiesMap.get(ProjectExamplesActivator.PROPERTY_PROJECT_NAME);
+ includedProjects.add(projectName);
+ String artifactId = (String)
propertiesMap.get(ProjectExamplesActivator.PROPERTY_ARTIFACT_ID);
+ IPath location = (IPath)
propertiesMap.get(ProjectExamplesActivator.PROPERTY_LOCATION_PATH);
+ String projectFolder = location.append(artifactId).toFile()
.getAbsolutePath();
- MavenModelManager mavenModelManager = MavenPlugin
+ MavenModelManager mavenModelManager = MavenPlugin
.getMavenModelManager();
- LocalProjectScanner scanner = new LocalProjectScanner(
- location.toFile(), //
+ LocalProjectScanner scanner = new LocalProjectScanner(location.toFile(),
projectFolder, true, mavenModelManager);
- try {
- scanner.run(monitor);
- } catch (InterruptedException e1) {
- ret[0] = false;
- return;
- }
+ try {
+ scanner.run(monitor);
+ } catch (InterruptedException e1) {
+ return false;
+ }
- Set<MavenProjectInfo> projectSet = collectProjects(scanner
- .getProjects());
- ProjectImportConfiguration importConfiguration = new ProjectImportConfiguration();
+ Set<MavenProjectInfo> projectSet = collectProjects(scanner.getProjects());
+ ProjectImportConfiguration importConfiguration = new ProjectImportConfiguration();
- for (MavenProjectInfo info : projectSet) {
- try {
- projectName = MavenProjectExamplesActivator
- .getProjectName(info, importConfiguration);
- if (!includedProjects.contains(projectName)) {
- includedProjects.add(projectName);
- }
- } catch (CoreException e) {
- MavenProjectExamplesActivator.log(e);
- ret[0] = false;
- }
+ for (MavenProjectInfo info : projectSet) {
+ try {
+ projectName = MavenProjectExamplesActivator.getProjectName(info,
importConfiguration);
+ if (!includedProjects.contains(projectName)) {
+ includedProjects.add(projectName);
}
- MavenProjectExamplesActivator.updateMavenConfiguration(projectName, includedProjects,
monitor);
+ } catch (CoreException e) {
+ MavenProjectExamplesActivator.log(e);
+ return false;
}
-
- });
- return ret[0];
+ }
+ MavenProjectExamplesActivator.updateMavenConfiguration(projectName, includedProjects,
monitor);
+ return true;
}
public Set<MavenProjectInfo> collectProjects(
@@ -129,4 +111,5 @@
private static Shell getActiveShell() {
return Display.getDefault().getActiveShell();
}
+
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -14,6 +14,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import org.apache.maven.model.Model;
import org.eclipse.core.resources.IProject;
@@ -50,7 +51,7 @@
@Override
public boolean importProject(ProjectExample projectDescription, File file,
- IProgressMonitor monitor) throws Exception {
+ Map<String, Object> propertiesMap, IProgressMonitor monitor) throws Exception {
List<ProjectExample> projects = new ArrayList<ProjectExample>();
projects.add(projectDescription);
IPath rootPath = getLocation();
Deleted:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -1,253 +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.maven.project.examples.wizard;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.maven.archetype.catalog.Archetype;
-import org.apache.maven.model.Model;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.internal.IMavenConstants;
-import org.eclipse.m2e.core.project.ProjectImportConfiguration;
-import org.eclipse.m2e.core.ui.internal.Messages;
-import org.eclipse.m2e.core.ui.internal.actions.SelectionUtil;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkingSet;
-import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
-import org.jboss.tools.maven.ui.Activator;
-import org.jboss.tools.project.examples.ProjectExamplesActivator;
-import org.jboss.tools.project.examples.model.ProjectExample;
-
-/**
- *
- * @author snjeza
- *
- */
-public class ArchetypeExamplesWizard extends Wizard implements INewWizard {
-
- private ProjectExample projectDescription;
- private ProjectImportConfiguration configuration;
- private ArchetypeExamplesWizardFirstPage simplePage;
- private ArchetypeExamplesWizardPage wizardPage;
- protected List<IWorkingSet> workingSets = new ArrayList<IWorkingSet>();
- private String projectName;
- private String artifactId;
- private IPath locationPath;
-
- public ArchetypeExamplesWizard(ProjectExample projectDescription) {
- super();
- setWindowTitle("New JBoss Project");
- setDefaultPageImageDescriptor(MavenProjectExamplesActivator.getNewWizardImageDescriptor());
- setNeedsProgressMonitor(true);
- this.projectDescription = projectDescription;
- }
-
- @Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- IWorkingSet workingSet = SelectionUtil.getSelectedWorkingSet(selection);
- if(workingSet != null) {
- this.workingSets.add(workingSet);
- }
- }
-
- @Override
- public boolean performFinish() {
- final Model model = wizardPage.getModel();
- final String groupId = model.getGroupId();
- artifactId = model.getArtifactId();
- final String version = model.getVersion();
- final String javaPackage = wizardPage.getJavaPackage();
- final Properties properties = wizardPage.getProperties();
- final Archetype archetype = wizardPage.getArchetype();
- locationPath = simplePage.getLocationPath();
- projectName = configuration.getProjectName(model);
- final IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- final IPath location = simplePage.getLocationPath();
-
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
-
- boolean pomExists =
location.append(projectName).append(IMavenConstants.POM_FILE_NAME).toFile().exists();
- if ( pomExists ) {
- MessageDialog.openError(getShell(), NLS.bind(Messages.wizardProjectJobFailed,
projectName), Messages.wizardProjectErrorPomAlreadyExists);
- return false;
- }
-
- final IWorkspaceRunnable wr = new IWorkspaceRunnable() {
-
- public void run(final IProgressMonitor monitor)
- throws CoreException {
-
- MavenPlugin.getProjectConfigurationManager().createArchetypeProject(
- project, location, archetype,
- groupId, artifactId, version, javaPackage, properties,
- configuration, monitor);
- }
- };
-
- final IRunnableWithProgress op = new IRunnableWithProgress() {
- public void run(final IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- try {
- final IWorkspace ws = ResourcesPlugin.getWorkspace();
- ws.run(wr, ws.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
- };
-
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- boolean configureSeam = store.getBoolean(Activator.CONFIGURE_SEAM);
- boolean configureJSF = store.getBoolean(Activator.CONFIGURE_JSF);
- boolean configurePortlet = store.getBoolean(Activator.CONFIGURE_PORTLET);
- boolean configureJSFPortlet = store.getBoolean(Activator.CONFIGURE_JSFPORTLET);
- boolean configureSeamPortlet = store.getBoolean(Activator.CONFIGURE_SEAMPORTLET);
- boolean configureCDI = store.getBoolean(Activator.CONFIGURE_CDI);
- boolean configureHibernate = store.getBoolean(Activator.CONFIGURE_HIBERNATE);
- boolean configureJaxRs = store.getBoolean(Activator.CONFIGURE_JAXRS);
-
- try {
- store.setValue(Activator.CONFIGURE_SEAM, false);
- store.setValue(Activator.CONFIGURE_JSF, false);
- store.setValue(Activator.CONFIGURE_PORTLET, false);
- store.setValue(Activator.CONFIGURE_JSFPORTLET, false);
- store.setValue(Activator.CONFIGURE_SEAMPORTLET, false);
- store.setValue(Activator.CONFIGURE_CDI, false);
- store.setValue(Activator.CONFIGURE_HIBERNATE, false);
- store.setValue(Activator.CONFIGURE_JAXRS, false);
- getContainer().run(true, false, op);
- } catch (InterruptedException e) {
- ProjectExamplesActivator.log(e);
- return true;
- } catch (InvocationTargetException e) {
- ProjectExamplesActivator.log(e);
- Throwable ex = e.getTargetException();
- String message = ex.getMessage();
- Throwable rootCause = getRootCause(ex);
- if (rootCause != null) {
- message += "\nRoot cause : " + rootCause.getMessage();
- }
- MessageDialog.openError(getShell(), "Error", message);
- return true;
- } finally {
- store.setValue(Activator.CONFIGURE_SEAM, configureSeam);
- store.setValue(Activator.CONFIGURE_JSF, configureJSF);
- store.setValue(Activator.CONFIGURE_PORTLET, configurePortlet);
- store.setValue(Activator.CONFIGURE_JSFPORTLET, configureJSFPortlet);
- store.setValue(Activator.CONFIGURE_SEAMPORTLET, configureSeamPortlet);
- store.setValue(Activator.CONFIGURE_CDI, configureCDI);
- store.setValue(Activator.CONFIGURE_HIBERNATE, configureHibernate);
- store.setValue(Activator.CONFIGURE_JAXRS, configureJaxRs);
- }
-
- return true;
- }
-
-
- private Throwable getRootCause(Throwable ex) {
- if (ex == null) return null;
- Throwable rootCause = getRootCause(ex.getCause());
- if (rootCause == null) {
- rootCause = ex;
- }
- return rootCause;
- }
-
- public void addPages() {
- configuration = new ProjectImportConfiguration();
- String profiles = projectDescription.getDefaultProfiles();
- if (profiles != null && profiles.trim().length() > 0) {
- configuration.getResolverConfiguration().setActiveProfiles(profiles);
- }
- simplePage = new ArchetypeExamplesWizardFirstPage(configuration, projectDescription,
workingSets);
- addPage(simplePage);
- String location =
ProjectExamplesActivator.getDefault().getPreferenceStore().getString(ProjectExamplesActivator.PROJECT_EXAMPLES_OUTPUT_DIRECTORY);
- if (location != null && location.trim().length() > 0) {
- simplePage.setLocationPath(new Path(location));
- }
- wizardPage = new ArchetypeExamplesWizardPage(configuration, projectDescription);
- wizardPage.setPageComplete(true);//We want to enable the finish button early
- addPage(wizardPage);
-
- simplePage.setProjectNameModifyListener(new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- wizardPage.setArtifactId(simplePage.getProjectName());
- if (ArchetypeExamplesWizard.this.getContainer().getCurrentPage() != null) {
- ArchetypeExamplesWizard.this.getContainer().updateButtons();
- }
- }
- });
-
- simplePage.setPackageNameModifyListener(new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- String packageName = ((Combo)e.getSource()).getText();
- wizardPage.setPackageName(packageName);
- if (ArchetypeExamplesWizard.this.getContainer().getCurrentPage() != null) {
- ArchetypeExamplesWizard.this.getContainer().updateButtons();
- }
- }
- });
-
-
- simplePage.setPropertyModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- wizardPage.updateArchetypeProperty("enterprise",
Boolean.toString(simplePage.isEnterpriseTargetRuntime()));
- }
- });
-
- }
-
- public String getProjectName() {
- return projectName;
- }
-
- public String getArtifactId() {
- return artifactId;
- }
-
- @Override
- public void createPageControls(Composite pageContainer) {
- super.createPageControls(pageContainer);
-
simplePage.setUseDefaultWorkspaceLocation(ProjectExamplesActivator.getDefault().getPreferenceStore().getBoolean(ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT));
- }
-
- public IPath getLocationPath() {
- return locationPath;
- }
-}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -12,6 +12,7 @@
import java.lang.reflect.Field;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -30,6 +31,8 @@
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.ui.internal.wizards.MavenProjectWizardLocationPage;
@@ -56,7 +59,10 @@
import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
import org.jboss.tools.maven.project.examples.Messages;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
import org.jboss.tools.project.examples.model.ProjectExample;
+import org.jboss.tools.project.examples.wizard.IProjectExamplesWizardPage;
+import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard2;
/**
* Simplified UI for the Maven Archetype Wizard, based off the original m2e
MavenProjectWizardLocationPage.
@@ -64,7 +70,7 @@
* @author Fred Bricon
*
*/
-public class ArchetypeExamplesWizardFirstPage extends MavenProjectWizardLocationPage {
+public class ArchetypeExamplesWizardFirstPage extends MavenProjectWizardLocationPage
implements IProjectExamplesWizardPage {
private static final String TARGET_RUNTIME = "targetRuntime";
private Label projectNameLabel;
@@ -79,8 +85,13 @@
private ModifyListener projectNameModifyListener;
private ModifyListener packageNameModifyListener;
private ModifyListener propertyModifyListener;
- private final ProjectExample projectDescription;
+ private ProjectExample projectDescription;
+ private ProjectExample projectExample;
+ public ArchetypeExamplesWizardFirstPage() {
+ super(new ProjectImportConfiguration(), "", "",new
ArrayList<IWorkingSet>());
+ }
+
public ArchetypeExamplesWizardFirstPage(
ProjectImportConfiguration configuration,
ProjectExample projectDescription, List<IWorkingSet> workingSet) {
@@ -89,7 +100,6 @@
setPageComplete(false);
}
-
@Override
protected void createAdditionalControls(Composite container) {
@@ -264,14 +274,16 @@
if (visible && !initialized) {
//Set defaults values from history here as the history is loaded in super.visible()
initDefaultValues();
- initialized = true;
- validate();
}
}
private void initDefaultValues() {
//JBIDE-10411 : provide sensible defaults for project name and package
+ if (projectExample == null || projectNameCombo == null) {
+ return;
+ }
+ projectDescription = projectExample;
String projectName = projectDescription.getArchetypeModel().getArtifactId();
if (StringUtils.isNotBlank(projectName)) {
IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
@@ -289,6 +301,8 @@
if (packageName != null) {
packageCombo.setText(packageName);
}
+ initialized = true;
+ validate();
}
private void createMissingRepositoriesWarning(Composite parent,
@@ -404,5 +418,73 @@
}
super.dispose();
}
+
+
+ @Override
+ public boolean finishPage() {
+ return true;
+ }
+
+
+ @Override
+ public String getProjectExampleType() {
+ return ProjectExamplesActivator.MAVEN_ARCHETYPE;
+ }
+
+ @Override
+ public void setProjectExample(ProjectExample projectExample) {
+ this.projectExample = projectExample;
+ if (projectExample != null) {
+ if (projectExample.getShortDescription() != null) {
+ setTitle(projectExample.getShortDescription());
+ }
+ if (projectExample.getDescription() != null) {
+ setDescription(ProjectExamplesActivator.getShortDescription(projectExample.getDescription()));
+ }
+ ProjectImportConfiguration configuration = getImportConfiguration();
+ if (configuration != null) {
+ String profiles = projectExample.getDefaultProfiles();
+ if (profiles != null && profiles.trim().length() > 0) {
+ configuration.getResolverConfiguration().setActiveProfiles(profiles);
+ }
+ }
+ initDefaultValues();
+ }
+ }
+ @Override
+ public IWizardPage getNextPage() {
+ IWizard wizard = getWizard();
+ if (wizard instanceof NewProjectExamplesWizard2) {
+ ProjectExample projectExample =
((NewProjectExamplesWizard2)wizard).getSelectedProjectExample();
+ if (projectExample != null && projectExample.getImportType() != null) {
+ List<IProjectExamplesWizardPage> pages =
((NewProjectExamplesWizard2)wizard).getContributedPages();
+ for (IProjectExamplesWizardPage page:pages) {
+ if (page == this) {
+ continue;
+ }
+ if (projectExample.getImportType().equals(page.getProjectExampleType())) {
+ return page;
+ }
+ }
+ }
+ }
+ return super.getNextPage();
+ }
+
+ @Override
+ public IWizardPage getPreviousPage() {
+ IWizard wizard = getWizard();
+ if (wizard instanceof NewProjectExamplesWizard2) {
+ return ((NewProjectExamplesWizard2) wizard).getRequirementsPage();
+ }
+ return super.getPreviousPage();
+ }
+
+ @Override
+ public Map<String, Object> getPropertiesMap() {
+ return null;
+ }
+
+
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -13,7 +13,9 @@
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.apache.maven.archetype.catalog.Archetype;
@@ -23,19 +25,30 @@
import org.apache.maven.archetype.metadata.RequiredProperty;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
import org.codehaus.plexus.util.StringUtils;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
+import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
+import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -48,8 +61,11 @@
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
import
org.jboss.tools.maven.project.examples.wizard.xpl.MavenProjectWizardArchetypeParametersPage;
+import org.jboss.tools.maven.ui.Activator;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
import org.jboss.tools.project.examples.model.ArchetypeModel;
import org.jboss.tools.project.examples.model.ProjectExample;
+import org.jboss.tools.project.examples.wizard.IProjectExamplesWizardPage;
/**
*
@@ -57,12 +73,19 @@
*
*/
public class ArchetypeExamplesWizardPage extends
- MavenProjectWizardArchetypeParametersPage {
+ MavenProjectWizardArchetypeParametersPage implements IProjectExamplesWizardPage {
private ProjectExample projectDescription;
private Composite warningLink;
private Boolean isEnterpriseRepoAvailable;
+ private ProjectExample projectExample;
+ private boolean initialized = false;
+ private Map<String, Object> propertiesMap = new HashMap<String, Object>();
+ public ArchetypeExamplesWizardPage() {
+ super(new ProjectImportConfiguration());
+ }
+
public ArchetypeExamplesWizardPage(
ProjectImportConfiguration configuration, ProjectExample projectDescription) {
super(configuration);
@@ -73,6 +96,13 @@
@Override
public void createControl(Composite parent) {
super.createControl(parent);
+ if (projectExample != null && !initialized) {
+ initialize();
+ }
+
+ }
+
+ protected void initialize() {
Archetype archetype = new Archetype();
ArchetypeModel archetypeModel = projectDescription.getArchetypeModel();
@@ -107,8 +137,8 @@
// when setVisible() is called in MavenProjectWizardArchetypeParametersPage.
// It needs to be called AFTER setArchetype(archetype) !!!
archetypeChanged = false;
-
resolverConfigurationComponent.setExpanded(!resolverConfigurationComponent.getResolverConfiguration().getActiveProfileList().isEmpty());
+ initialized = true;
}
@Override
@@ -307,5 +337,153 @@
isEnterpriseRepoAvailable = MavenArtifactHelper.isEnterpriseRepositoryAvailable();
return isEnterpriseRepoAvailable.booleanValue();
}
+
+ private Throwable getRootCause(Throwable ex) {
+ if (ex == null) return null;
+ Throwable rootCause = getRootCause(ex.getCause());
+ if (rootCause == null) {
+ rootCause = ex;
+ }
+ return rootCause;
+ }
+ @Override
+ public boolean finishPage() {
+ final Model model = getModel();
+ final String groupId = model.getGroupId();
+ final String artifactId = model.getArtifactId();
+ final String version = model.getVersion();
+ final String javaPackage = getJavaPackage();
+ final Properties properties = getProperties();
+ final Archetype archetype = getArchetype();
+ ArchetypeExamplesWizardFirstPage simplePage = getSimplePage();
+ if (simplePage == null) {
+ MavenProjectExamplesActivator.log("Cannot import maven archetype");
+ return false;
+ }
+ IPath locationPath = simplePage.getLocationPath();
+ final ProjectImportConfiguration configuration = getImportConfiguration();
+ String projectName = configuration.getProjectName(model);
+ propertiesMap.put(ProjectExamplesActivator.PROPERTY_PROJECT_NAME, projectName);
+ final IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ final IPath location = simplePage.getLocationPath();
+ propertiesMap.put(ProjectExamplesActivator.PROPERTY_LOCATION_PATH, location);
+ propertiesMap.put(ProjectExamplesActivator.PROPERTY_ARTIFACT_ID, artifactId);
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+
+ boolean pomExists =
location.append(projectName).append(IMavenConstants.POM_FILE_NAME).toFile().exists();
+ if ( pomExists ) {
+ MessageDialog.openError(getShell(), NLS.bind(Messages.wizardProjectJobFailed,
projectName), Messages.wizardProjectErrorPomAlreadyExists);
+ return false;
+ }
+
+ final IWorkspaceRunnable wr = new IWorkspaceRunnable() {
+
+ public void run(final IProgressMonitor monitor)
+ throws CoreException {
+
+ MavenPlugin.getProjectConfigurationManager().createArchetypeProject(
+ project, location, archetype,
+ groupId, artifactId, version, javaPackage, properties,
+ configuration, monitor);
+ }
+ };
+
+ final IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(final IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ try {
+ final IWorkspace ws = ResourcesPlugin.getWorkspace();
+ ws.run(wr, ws.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ };
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ boolean configureSeam = store.getBoolean(Activator.CONFIGURE_SEAM);
+ boolean configureJSF = store.getBoolean(Activator.CONFIGURE_JSF);
+ boolean configurePortlet = store.getBoolean(Activator.CONFIGURE_PORTLET);
+ boolean configureJSFPortlet = store.getBoolean(Activator.CONFIGURE_JSFPORTLET);
+ boolean configureSeamPortlet = store.getBoolean(Activator.CONFIGURE_SEAMPORTLET);
+ boolean configureCDI = store.getBoolean(Activator.CONFIGURE_CDI);
+ boolean configureHibernate = store.getBoolean(Activator.CONFIGURE_HIBERNATE);
+ boolean configureJaxRs = store.getBoolean(Activator.CONFIGURE_JAXRS);
+
+ try {
+ store.setValue(Activator.CONFIGURE_SEAM, false);
+ store.setValue(Activator.CONFIGURE_JSF, false);
+ store.setValue(Activator.CONFIGURE_PORTLET, false);
+ store.setValue(Activator.CONFIGURE_JSFPORTLET, false);
+ store.setValue(Activator.CONFIGURE_SEAMPORTLET, false);
+ store.setValue(Activator.CONFIGURE_CDI, false);
+ store.setValue(Activator.CONFIGURE_HIBERNATE, false);
+ store.setValue(Activator.CONFIGURE_JAXRS, false);
+ getContainer().run(true, false, op);
+ } catch (InterruptedException e) {
+ ProjectExamplesActivator.log(e);
+ return true;
+ } catch (InvocationTargetException e) {
+ ProjectExamplesActivator.log(e);
+ Throwable ex = e.getTargetException();
+ String message = ex.getMessage();
+ Throwable rootCause = getRootCause(ex);
+ if (rootCause != null) {
+ message += "\nRoot cause : " + rootCause.getMessage();
+ }
+ MessageDialog.openError(getShell(), "Error", message);
+ return true;
+ } finally {
+ store.setValue(Activator.CONFIGURE_SEAM, configureSeam);
+ store.setValue(Activator.CONFIGURE_JSF, configureJSF);
+ store.setValue(Activator.CONFIGURE_PORTLET, configurePortlet);
+ store.setValue(Activator.CONFIGURE_JSFPORTLET, configureJSFPortlet);
+ store.setValue(Activator.CONFIGURE_SEAMPORTLET, configureSeamPortlet);
+ store.setValue(Activator.CONFIGURE_CDI, configureCDI);
+ store.setValue(Activator.CONFIGURE_HIBERNATE, configureHibernate);
+ store.setValue(Activator.CONFIGURE_JAXRS, configureJaxRs);
+ }
+
+ return true;
+ }
+
+ private ArchetypeExamplesWizardFirstPage getSimplePage() {
+ IWizardPage[] pages = getWizard().getPages();
+ for (IWizardPage page:pages) {
+ if (page instanceof ArchetypeExamplesWizardFirstPage) {
+ return (ArchetypeExamplesWizardFirstPage) page;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getProjectExampleType() {
+ return ProjectExamplesActivator.MAVEN_ARCHETYPE;
+ }
+
+ @Override
+ public void setProjectExample(ProjectExample projectExample) {
+ this.projectExample = projectExample;
+ if (projectExample != null) {
+ if (projectExample.getShortDescription() != null) {
+ setTitle(projectExample.getShortDescription());
+ }
+ if (projectExample.getDescription() != null) {
+ setDescription(ProjectExamplesActivator
+ .getShortDescription(projectExample.getDescription()));
+ }
+ projectDescription = projectExample;
+ if (getContainer() != null) {
+ initialize();
+ }
+ }
+ }
+
+ @Override
+ public Map<String, Object> getPropertiesMap() {
+ return propertiesMap ;
+ }
+
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/xpl/UpdateMavenProjectJob.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/xpl/UpdateMavenProjectJob.java 2012-02-15
22:20:03 UTC (rev 38783)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/xpl/UpdateMavenProjectJob.java 2012-02-15
22:40:09 UTC (rev 38784)
@@ -33,10 +33,8 @@
import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.m2e.core.ui.internal.actions.OpenMavenConsoleAction;
import org.eclipse.m2e.core.ui.internal.util.M2EUIUtils;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.progress.IProgressConstants;
-import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
/**
* Class copied from org.eclipse.m2e.core.ui.internal.UpdateMavenProjectJob in m2e 1.1
@@ -93,8 +91,8 @@
setProperty(IProgressConstants.ACTION_PROPERTY, new OpenMavenConsoleAction());
monitor.beginTask(getName(), projects.length);
- long l1 = System.currentTimeMillis();
- MavenProjectExamplesActivator.log("Update started"); //$NON-NLS-1$
+ //long l1 = System.currentTimeMillis();
+ //MavenProjectExamplesActivator.log("Update started"); //$NON-NLS-1$
MultiStatus status = null;
//project names to the errors encountered when updating them
@@ -140,8 +138,8 @@
if(updateErrors.size() > 0) {
handleErrors(updateErrors);
}
- long l2 = System.currentTimeMillis();
- MavenProjectExamplesActivator.log(NLS.bind("Update completed: {0} sec",
((l2 - l1) / 1000))); //$NON-NLS-1$
+ //long l2 = System.currentTimeMillis();
+ //MavenProjectExamplesActivator.log(NLS.bind("Update completed: {0} sec",
((l2 - l1) / 1000))); //$NON-NLS-1$
return status != null ? status : Status.OK_STATUS;
}