JBoss Tools SVN: r38790 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-02-15 18:15:44 -0500 (Wed, 15 Feb 2012)
New Revision: 38790
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
Log:
[JBIDE-10901] setting widget values to imported application
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-02-15 23:07:40 UTC (rev 38789)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-02-15 23:15:44 UTC (rev 38790)
@@ -155,6 +155,7 @@
public void loadCartridges() throws OpenShiftException {
setCartridges(getUser().getCartridges());
+ refreshSelectedCartridge();
}
public void setCartridges(List<ICartridge> cartridges) {
@@ -169,6 +170,15 @@
return wizardModel.getApplicationCartridge();
}
+ /**
+ * forces property change listeners to update their value
+ */
+ protected void refreshSelectedCartridge() {
+ ICartridge selectedCartridge = getSelectedCartridge();
+ setSelectedCartridge((ICartridge) null);
+ setSelectedCartridge(selectedCartridge);
+ }
+
public void setSelectedCartridge(ICartridge cartridge) {
firePropertyChange(PROPERTY_SELECTED_CARTRIDGE
, wizardModel.getApplicationCartridge()
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java 2012-02-15 23:07:40 UTC (rev 38789)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java 2012-02-15 23:15:44 UTC (rev 38790)
@@ -184,7 +184,7 @@
public IServerType getServerType();
- public void setServerType(IServerType serverType);
+ public IServerType setServerType(IServerType serverType);
public boolean isUseExistingApplication();
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-02-15 23:07:40 UTC (rev 38789)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-02-15 23:15:44 UTC (rev 38790)
@@ -311,8 +311,8 @@
}
@Override
- public void setServerType(IServerType serverType) {
- setProperty(SERVER_TYPE, serverType);
+ public IServerType setServerType(IServerType serverType) {
+ return (IServerType) setProperty(SERVER_TYPE, serverType);
}
private void setPublicationMode(String mode) {
@@ -326,7 +326,8 @@
@Override
public boolean setUseExistingApplication(boolean useExistingApplication) {
- return (Boolean) setProperty(USE_EXISTING_APPLICATION, useExistingApplication);
+ Boolean isUseExistingApplication = (Boolean) setProperty(USE_EXISTING_APPLICATION, useExistingApplication);
+ return isUseExistingApplication != null && isUseExistingApplication;
}
protected void setUseExistingApplication(IApplication application) {
@@ -363,7 +364,7 @@
public Set<IEmbeddableCartridge> getSelectedEmbeddableCartridges() {
@SuppressWarnings("unchecked")
Set<IEmbeddableCartridge> selectedEmbeddableCartridges =
- (Set<IEmbeddableCartridge>) dataModel.get(KEY_SELECTED_EMBEDDABLE_CARTRIDGES);
+ (Set<IEmbeddableCartridge>) getProperty(KEY_SELECTED_EMBEDDABLE_CARTRIDGES);
if (selectedEmbeddableCartridges == null) {
selectedEmbeddableCartridges = new HashSet<IEmbeddableCartridge>();
setSelectedEmbeddableCartridges(selectedEmbeddableCartridges);
@@ -371,16 +372,16 @@
return selectedEmbeddableCartridges;
}
+ @SuppressWarnings("unchecked")
@Override
public Set<IEmbeddableCartridge> setSelectedEmbeddableCartridges(
Set<IEmbeddableCartridge> selectedEmbeddableCartridges) {
- dataModel.put(KEY_SELECTED_EMBEDDABLE_CARTRIDGES, selectedEmbeddableCartridges);
- return selectedEmbeddableCartridges;
+ return (Set<IEmbeddableCartridge>) setProperty(KEY_SELECTED_EMBEDDABLE_CARTRIDGES, selectedEmbeddableCartridges);
}
@Override
public ICartridge setApplicationCartridge(ICartridge cartridge) {
- return (ICartridge) dataModel.put(APPLICATION_CARTRIDGE, cartridge);
+ return (ICartridge) setProperty(APPLICATION_CARTRIDGE, cartridge);
}
protected void setApplicationCartridge(IApplication application) {
@@ -392,13 +393,12 @@
@Override
public ICartridge getApplicationCartridge() {
- return (ICartridge) dataModel.get(APPLICATION_CARTRIDGE);
+ return (ICartridge) getProperty(APPLICATION_CARTRIDGE);
}
@Override
public String setApplicationName(String applicationName) {
- firePropertyChange(APPLICATION_NAME, getApplicationName(), dataModel.put(APPLICATION_NAME, applicationName));
- return applicationName;
+ return (String) setProperty(APPLICATION_NAME, applicationName);
}
protected void setApplicationName(IApplication application) {
@@ -410,18 +410,17 @@
@Override
public String getApplicationName() {
- return (String) dataModel.get(APPLICATION_NAME);
+ return (String) getProperty(APPLICATION_NAME);
}
@Override
public IUser getUser() {
- return (IUser) dataModel.get(USER);
+ return (IUser) getProperty(USER);
}
@Override
public IUser setUser(IUser user) {
- dataModel.put(USER, user);
- return user;
+ return (IUser) setProperty(USER, user);
}
@Override
14 years, 1 month
JBoss Tools SVN: r38789 - in trunk: common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-02-15 18:07:40 -0500 (Wed, 15 Feb 2012)
New Revision: 38789
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/ValuedQualifier.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
Log:
Wizard 'Specify CDI Bean for the Injection Point' does not compute correctly condition 'can finish' https://issues.jboss.org/browse/JBIDE-10637
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/ValuedQualifier.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/ValuedQualifier.java 2012-02-15 22:56:28 UTC (rev 38788)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/ValuedQualifier.java 2012-02-15 23:07:40 UTC (rev 38789)
@@ -37,6 +37,26 @@
pair.type = "String";
}else if(mvp.getValueKind() == IMemberValuePair.K_CHAR){
pair.type = "char";
+ }else if(mvp.getValueKind() == IMemberValuePair.K_CLASS){
+ pair.type = "Class";
+ }else if(mvp.getValueKind() == IMemberValuePair.K_BOOLEAN){
+ pair.type = "boolean";
+ }else if(mvp.getValueKind() == IMemberValuePair.K_BYTE){
+ pair.type = "byte";
+ }else if(mvp.getValueKind() == IMemberValuePair.K_DOUBLE){
+ pair.type = "double";
+ }else if(mvp.getValueKind() == IMemberValuePair.K_FLOAT){
+ pair.type = "float";
+ }else if(mvp.getValueKind() == IMemberValuePair.K_INT){
+ pair.type = "int";
+ }else if(mvp.getValueKind() == IMemberValuePair.K_LONG){
+ pair.type = "long";
+ }else if(mvp.getValueKind() == IMemberValuePair.K_QUALIFIED_NAME){
+ pair.type = "name";
+ }else if(mvp.getValueKind() == IMemberValuePair.K_SHORT){
+ pair.type = "short";
+ }else if(mvp.getValueKind() == IMemberValuePair.K_SIMPLE_NAME){
+ pair.type = "name";
}
pairs.add(pair);
}
@@ -69,7 +89,7 @@
}else if(pair.type.equals("String")){
pair.value = "default";
}else{
- pair.value = "String.class";
+ pair.value = "String";
}
}
pairs.add(pair);
@@ -141,6 +161,10 @@
text += "\""+pair.value+"\"";
}else{
text += pair.value;
+ if(!CDIMarkerResolutionUtils.primitives.contains(pair.type)){
+ text += ".class";
+ }
+
}
first = false;
}
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2012-02-15 22:56:28 UTC (rev 38788)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2012-02-15 23:07:40 UTC (rev 38789)
@@ -80,7 +80,7 @@
private static final int NUMBER_OF_STRINGS = 3;
- static final HashSet<String> primitives = new HashSet<String>();
+ public static final HashSet<String> primitives = new HashSet<String>();
static{
primitives.add("void"); //$NON-NLS-1$
primitives.add("int"); //$NON-NLS-1$
14 years, 1 month
JBoss Tools SVN: r38787 - in trunk/ws/plugins: org.jboss.tools.ws.creation.core/META-INF and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: bfitzpat
Date: 2012-02-15 17:54:17 -0500 (Wed, 15 Feb 2012)
New Revision: 38787
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
Log:
[JBIDE-10827] Updating plug-in versions in MANIFEST.MF to get it to build and install successfully
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2012-02-15 22:45:01 UTC (rev 38786)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2012-02-15 22:54:17 UTC (rev 38787)
@@ -5,24 +5,24 @@
Bundle-Version: 1.2.2.qualifier
Bundle-Localization: plugin
Bundle-Activator: org.jboss.tools.ws.core.JBossWSCorePlugin
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.wst.common.project.facet.core,
- org.eclipse.wst.common.frameworks,
- org.eclipse.core.resources,
- org.eclipse.jst.ws,
- org.eclipse.jdt.core,
- org.eclipse.jdt.launching,
- org.eclipse.jst.jsf.core,
- org.eclipse.jst.jsf.ui,
- org.eclipse.wst.common.modulecore,
- org.eclipse.jdt.launching,
- org.eclipse.jst.jsf.core,
- org.eclipse.jst.jsf.ui,
- org.eclipse.jdt.launching,
- org.eclipse.jst.j2ee,
- org.eclipse.jst.ws.consumption.ui,
- org.jboss.ide.eclipse.as.classpath.core
+Require-Bundle: org.eclipse.ui;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.core.runtime;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.200,1.5.0)",
+ org.eclipse.wst.common.frameworks;bundle-version="[1.2.101,1.3.0)",
+ org.eclipse.core.resources;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.jst.ws;bundle-version="[1.0.509,1.1.0)",
+ org.eclipse.jdt.core;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.jdt.launching;bundle-version="[3.6.1,3.6.2)",
+ org.eclipse.jst.jsf.core;bundle-version="[1.3.105,1.4.0)",
+ org.eclipse.jst.jsf.ui;bundle-version="[1.3.2,1.4.0)",
+ org.eclipse.wst.common.modulecore;bundle-version="[1.2.101,1.3.0)",
+ org.eclipse.jdt.launching;bundle-version="[3.6.1,3.6.2)",
+ org.eclipse.jst.jsf.core;bundle-version="[1.3.105,1.4.0)",
+ org.eclipse.jst.jsf.ui;bundle-version="[1.3.2,1.4.0)",
+ org.eclipse.jdt.launching;bundle-version="[3.6.1,3.7.0)",
+ org.eclipse.jst.j2ee;bundle-version="[1.1.501,1.2.0)",
+ org.eclipse.jst.ws.consumption.ui;bundle-version="[1.1.401,1.2.0)",
+ org.jboss.ide.eclipse.as.classpath.core;bundle-version="[2.3.0,2.4.0)"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %PLUGIN_PROVIDER
Export-Package: org.jboss.tools.ws.core,
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2012-02-15 22:45:01 UTC (rev 38786)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2012-02-15 22:54:17 UTC (rev 38787)
@@ -5,41 +5,41 @@
Bundle-Version: 1.2.2.qualifier
Bundle-Activator: org.jboss.tools.ws.creation.core.JBossWSCreationCorePlugin
Bundle-Vendor: %Bundle-Vendor.0
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.wst.common.frameworks,
- org.eclipse.wst.ws,
- org.eclipse.core.resources,
- org.eclipse.jst.ws,
- org.eclipse.jem.util,
+Require-Bundle: org.eclipse.ui;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.core.runtime;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.wst.common.frameworks;bundle-version="[1.2.101,1.3.0)",
+ org.eclipse.wst.ws;bundle-version="[1.1.203,1.2.0)",
+ org.eclipse.core.resources;bundle-version="[3.7.1,3.8.0)",
+ org.eclipse.jst.ws;bundle-version="[1.0.509,1.1.0)",
+ org.eclipse.jem.util;bundle-version="[2.1.100,2.2.0)",
org.jboss.tools.ws.core,
- org.eclipse.wst.wsdl,
- org.eclipse.wst.command.env.core,
- org.eclipse.wst.command.env,
- org.apache.ant,
- org.apache.xerces,
- org.eclipse.jst.j2ee;visibility:=reexport,
- org.eclipse.jst.j2ee.core;visibility:=reexport,
- org.eclipse.jst.jee,
- org.eclipse.emf.common,
- org.eclipse.emf.ecore,
- org.eclipse.jdt.core,
- org.eclipse.jface.text,
- org.eclipse.core.filebuffers,
- org.eclipse.jdt.ui,
- org.eclipse.wst.common.project.facet.core,
- org.eclipse.wst.server.core,
- org.eclipse.jem.util,
+ org.eclipse.wst.wsdl;bundle-version="[1.2.202,1.3.0)",
+ org.eclipse.wst.command.env.core;bundle-version="[1.0.205,1.1.0)",
+ org.eclipse.wst.command.env;bundle-version="[1.0.409,1.1.0)",
+ org.apache.ant;bundle-version="[1.8.2,1.9.0)",
+ org.apache.xerces;bundle-version="[2.9.0,3.0.0)",
+ org.eclipse.jst.j2ee;bundle-version="[1.1.501,1.2.0)";visibility:=reexport,
+ org.eclipse.jst.j2ee.core;bundle-version="[1.2.101,1.3.0)";visibility:=reexport,
+ org.eclipse.jst.jee;bundle-version="[1.0.401,1.1.0)",
+ org.eclipse.emf.common;bundle-version="[2.7.0,2.8.0)",
+ org.eclipse.emf.ecore;bundle-version="[2.7.0,2.8.0)",
+ org.eclipse.jdt.core;bundle-version="[3.7.1,3.8.0)",
+ org.eclipse.jface.text;bundle-version="[3.7.1,3.8.0)",
+ org.eclipse.core.filebuffers;bundle-version="[3.5.200,3.6.0)",
+ org.eclipse.jdt.ui;bundle-version="[3.7.1,3.8.0)",
+ org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.200,1.5.0)",
+ org.eclipse.wst.server.core;bundle-version="[1.1.303,1.2.0)",
+ org.eclipse.jem.util;bundle-version="[2.1.100,2.2.0)",
org.jboss.tools.common,
org.jboss.ide.eclipse.as.classpath.core,
- org.eclipse.jst.server.core,
- org.eclipse.jdt,
- org.eclipse.jdt.launching,
- org.eclipse.debug.core,
- org.eclipse.jst.jee.web,
+ org.eclipse.jst.server.core;bundle-version="[1.2.202,1.3.0)",
+ org.eclipse.jdt;bundle-version="[3.7.1,3.8.0)",
+ org.eclipse.jdt.launching;bundle-version="[3.6.1,3.7.0)",
+ org.eclipse.debug.core;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.jst.jee.web;bundle-version="[1.0.301,1.1.0)",
javax.wsdl;visibility:=reexport,
- org.eclipse.jst.ws.annotations.core,
- org.eclipse.wst.common.emfworkbench.integration
+ org.eclipse.jst.ws.annotations.core;bundle-version="[1.1.0,1.2.0)",
+ org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.2.101,1.3.0)"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.creation.core,
org.jboss.tools.ws.creation.core.commands,
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF 2012-02-15 22:45:01 UTC (rev 38786)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF 2012-02-15 22:54:17 UTC (rev 38787)
@@ -6,26 +6,26 @@
Bundle-Version: 1.2.2.qualifier
Bundle-Activator: org.jboss.tools.ws.creation.ui.JBossWSCreationUIPlugin
Bundle-Vendor: %PLUGIN_PROVIDER
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.core.resources,
- org.eclipse.jst.ws.consumption.ui,
- org.eclipse.wst.ws,
- org.eclipse.wst.common.environment,
- org.eclipse.wst.command.env.core,
- org.eclipse.emf.common,
- org.eclipse.wst.common.frameworks,
- org.eclipse.wst.command.env.ui,
- org.eclipse.jst.ws,
- org.eclipse.wst.command.env,
- org.eclipse.jdt.core,
- org.eclipse.jst.ws.ui,
+Require-Bundle: org.eclipse.ui;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.core.runtime;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.core.resources;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.jst.ws.consumption.ui;bundle-version="[1.1.401,1.2.0)",
+ org.eclipse.wst.ws;bundle-version="[1.1.203,1.2.0)",
+ org.eclipse.wst.common.environment;bundle-version="[1.0.400,1.1.0)",
+ org.eclipse.wst.command.env.core;bundle-version="[1.0.205,1.1.0)",
+ org.eclipse.emf.common;bundle-version="[2.7.0,2.8.0)",
+ org.eclipse.wst.common.frameworks;bundle-version="[1.2.101,1.3.0)",
+ org.eclipse.wst.command.env.ui;bundle-version="[1.1.103,1.2.0)",
+ org.eclipse.jst.ws;bundle-version="[1.0.509,1.1.0)",
+ org.eclipse.wst.command.env;bundle-version="[1.0.409,1.1.0)",
+ org.eclipse.jdt.core;bundle-version="[3.7.1,3.8.0)",
+ org.eclipse.jst.ws.ui;bundle-version="[1.0.403,1.1.0)",
org.jboss.tools.ws.creation.core,
org.jboss.tools.ws.core,
- org.eclipse.jst.ws.creation.ui,
- org.eclipse.wst.common.modulecore,
+ org.eclipse.jst.ws.creation.ui;bundle-version="[1.0.609,1.1.0)",
+ org.eclipse.wst.common.modulecore;bundle-version="[1.2.101,1.3.0)",
org.jboss.tools.ws.ui,
- org.eclipse.jdt.ui
+ org.eclipse.jdt.ui;bundle-version="[3.7.1,3.8.0)"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.creation.ui.wsrt
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF 2012-02-15 22:45:01 UTC (rev 38786)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF 2012-02-15 22:54:17 UTC (rev 38787)
@@ -6,28 +6,28 @@
Bundle-SymbolicName: org.jboss.tools.ws.jaxrs.core;singleton:=true
Bundle-Version: 1.2.2.qualifier
Bundle-Activator: org.jboss.tools.ws.jaxrs.core.JBossJaxrsCorePlugin
-Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0";visibility:=reexport,
- org.eclipse.core.resources;bundle-version="3.7.100";visibility:=reexport,
- org.eclipse.equinox.ds;bundle-version="1.3.0";visibility:=reexport,
- org.eclipse.jdt.core;bundle-version="3.7.0";visibility:=reexport,
- org.eclipse.jdt.launching;bundle-version="3.6.0";visibility:=reexport,
- org.eclipse.jdt.launching.macosx;bundle-version="3.2.100";resolution:=optional;visibility:=reexport,
- org.eclipse.jface.text;bundle-version="3.7.0";visibility:=reexport,
- org.eclipse.jst.j2ee.ejb;bundle-version="1.1.502",
- org.eclipse.ui.workbench;bundle-version="3.7.0";visibility:=reexport,
- org.eclipse.jdt.core.manipulation;bundle-version="1.3.0";visibility:=reexport,
- org.eclipse.ui.editors;bundle-version="3.7.0";visibility:=reexport,
- org.eclipse.core.commands;bundle-version="3.6.0";visibility:=reexport,
- org.eclipse.ui;bundle-version="3.7.0";visibility:=reexport,
- org.eclipse.ltk.core.refactoring;bundle-version="3.5.200";visibility:=reexport,
- org.eclipse.wst.validation;bundle-version="1.2.300";visibility:=reexport,
- org.eclipse.jst.j2ee.web;bundle-version="1.1.301";visibility:=reexport,
- org.eclipse.jst.j2ee.core;bundle-version="1.1.301";visibility:=reexport,
- org.eclipse.core.resources;bundle-version="3.5.1";visibility:=reexport,
- org.eclipse.jst.j2ee;bundle-version="1.1.301";visibility:=reexport,
- org.eclipse.emf.ecore;bundle-version="2.5.0";visibility:=reexport,
- org.eclipse.wst.common.frameworks.ui;bundle-version="1.1.301",
- org.eclipse.jface.text;bundle-version="3.7.1"
+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.7.0,3.8.0)";visibility:=reexport,
+ org.eclipse.core.resources;bundle-version="[3.7.100,3.8.0)";visibility:=reexport,
+ org.eclipse.equinox.ds;bundle-version="[1.3.0,1.4.0)";visibility:=reexport,
+ org.eclipse.jdt.core;bundle-version="[3.7.0,3.8.0)";visibility:=reexport,
+ org.eclipse.jdt.launching;bundle-version="[3.6.0,3.7.0)";visibility:=reexport,
+ org.eclipse.jdt.launching.macosx;bundle-version="[3.2.100,3.3.0)";resolution:=optional;visibility:=reexport,
+ org.eclipse.jface.text;bundle-version="[3.7.0,3.8.0)";visibility:=reexport,
+ org.eclipse.jst.j2ee.ejb;bundle-version="[1.1.502,1.2.0)",
+ org.eclipse.ui.workbench;bundle-version="[3.7.0,3.8.0)";visibility:=reexport,
+ org.eclipse.jdt.core.manipulation;bundle-version="[1.3.0,1.5.0)";visibility:=reexport,
+ org.eclipse.ui.editors;bundle-version="[3.7.0,3.8.0)";visibility:=reexport,
+ org.eclipse.core.commands;bundle-version="[3.6.0,3.7.0)";visibility:=reexport,
+ org.eclipse.ui;bundle-version="[3.7.0,3.8.0)";visibility:=reexport,
+ org.eclipse.ltk.core.refactoring;bundle-version="[3.5.200,3.6.0)";visibility:=reexport,
+ org.eclipse.wst.validation;bundle-version="[1.2.300,1.3.0)";visibility:=reexport,
+ org.eclipse.jst.j2ee.web;bundle-version="[1.1.301,1.2.0)";visibility:=reexport,
+ org.eclipse.jst.j2ee.core;bundle-version="[1.1.301,1.3.0)";visibility:=reexport,
+ org.eclipse.core.resources;bundle-version="[3.5.1,3.8.0)";visibility:=reexport,
+ org.eclipse.jst.j2ee;bundle-version="[1.1.301,1.2.0)";visibility:=reexport,
+ org.eclipse.emf.ecore;bundle-version="[2.5.0,2.8.0)";visibility:=reexport,
+ org.eclipse.wst.common.frameworks.ui;bundle-version="[1.1.301,1.3.0)",
+ org.eclipse.jface.text;bundle-version="[3.7.1,3.8.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: javax.ws.rs,
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/META-INF/MANIFEST.MF 2012-02-15 22:45:01 UTC (rev 38786)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/META-INF/MANIFEST.MF 2012-02-15 22:54:17 UTC (rev 38787)
@@ -6,37 +6,37 @@
Bundle-SymbolicName: org.jboss.tools.ws.jaxrs.ui;singleton:=true
Bundle-Version: 1.2.2.qualifier
Bundle-Activator: org.jboss.tools.ws.jaxrs.ui.JBossJaxrsUIPlugin
-Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
- org.eclipse.ui.ide;bundle-version="3.7.0",
- org.eclipse.core.runtime;visibility:=reexport,
- org.eclipse.jdt.core;bundle-version="3.6.0",
- org.eclipse.jdt.core.manipulation;bundle-version="1.3.0",
+Require-Bundle: org.eclipse.ui;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.ui.ide;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.core.runtime;bundle-version="[3.7.0,3.8.0)";visibility:=reexport,
+ org.eclipse.jdt.core;bundle-version="[3.6.0,3.8.0)",
+ org.eclipse.jdt.core.manipulation;bundle-version="[1.3.0,1.5.0)",
org.jboss.tools.ws.jaxrs.core;bundle-version="1.2.0",
- org.eclipse.ui.navigator;bundle-version="3.5.0",
- org.eclipse.ui.navigator.resources;bundle-version="3.4.200",
- org.eclipse.ui.views;bundle-version="3.5.0",
- org.eclipse.core.resources;bundle-version="3.6.0",
- org.eclipse.jface.databinding;bundle-version="1.4.0",
- org.eclipse.jst.ws.jaxrs.core;bundle-version="1.0.200",
- org.eclipse.jst.common.project.facet.core;bundle-version="1.4.102",
- org.eclipse.jst.common.project.facet.ui;bundle-version="1.4.102",
- org.eclipse.ui.workbench.texteditor;bundle-version="3.6.0",
- org.eclipse.wst.common.project.facet.core;bundle-version="1.4.102",
- org.eclipse.jdt.ui;bundle-version="3.7.0",
- org.eclipse.jdt.doc.user;bundle-version="3.7.0";resolution:=optional,
- org.eclipse.core.resources;bundle-version="3.7.0",
- org.eclipse.equinox.ds;bundle-version="1.3.0",
- org.eclipse.jdt.core;bundle-version="3.7.0",
- org.eclipse.jface.text;bundle-version="3.7.0",
- org.eclipse.ui.workbench;bundle-version="3.7.0",
- org.eclipse.jdt.core.manipulation;bundle-version="1.4.0",
- org.eclipse.ui.editors;bundle-version="3.7.0",
- org.eclipse.core.commands;bundle-version="3.6.0",
- org.eclipse.ltk.core.refactoring;bundle-version="3.5.200",
- org.eclipse.wst.validation;bundle-version="1.2.300",
- org.eclipse.wst.server.core,
- org.eclipse.debug.core;bundle-version="3.7.0",
- org.eclipse.debug.ui;bundle-version="3.7.101"
+ org.eclipse.ui.navigator;bundle-version="[3.5.0,3.6.0)",
+ org.eclipse.ui.navigator.resources;bundle-version="[3.4.200,3.5.0)",
+ org.eclipse.ui.views;bundle-version="[3.5.0,3.7.0)",
+ org.eclipse.core.resources;bundle-version="[3.6.0,3.8.0)",
+ org.eclipse.jface.databinding;bundle-version="[1.4.0,1.6.0)",
+ org.eclipse.jst.ws.jaxrs.core;bundle-version="[1.0.200,1.1.0)",
+ org.eclipse.jst.common.project.facet.core;bundle-version="[1.4.102,1.5.0)",
+ org.eclipse.jst.common.project.facet.ui;bundle-version="[1.4.102,1.5.0)",
+ org.eclipse.ui.workbench.texteditor;bundle-version="[3.6.0,3.8.0)",
+ org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.102,1.5.0)",
+ org.eclipse.jdt.ui;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.jdt.doc.user;bundle-version="[3.7.0,3.8.0)";resolution:=optional,
+ org.eclipse.core.resources;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.equinox.ds;bundle-version="[1.3.0,1.4.0)",
+ org.eclipse.jdt.core;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.jface.text;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.ui.workbench;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.jdt.core.manipulation;bundle-version="[1.4.0,1.5.0)",
+ org.eclipse.ui.editors;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.core.commands;bundle-version="[3.6.0,3.7.0)",
+ org.eclipse.ltk.core.refactoring;bundle-version="[3.5.200,3.6.0)",
+ org.eclipse.wst.validation;bundle-version="[1.2.300,1.3.0)",
+ org.eclipse.wst.server.core;bundle-version="[1.1.303,1.2.0)",
+ org.eclipse.debug.core;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.debug.ui;bundle-version="[3.7.101,3.8.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2012-02-15 22:45:01 UTC (rev 38786)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2012-02-15 22:54:17 UTC (rev 38787)
@@ -5,36 +5,36 @@
Bundle-Version: 1.2.2.qualifier
Bundle-Activator: org.jboss.tools.ws.ui.JBossWSUIPlugin
Bundle-Localization: plugin
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.core.resources,
+Require-Bundle: org.eclipse.ui;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.core.runtime;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.core.resources;bundle-version="[3.7.100,3.8.0)",
org.jboss.tools.ws.core,
- org.eclipse.ui.ide,
- org.eclipse.wst.common.project.facet.core,
- org.eclipse.jdt.core,
- org.eclipse.jst.j2ee,
- org.eclipse.jem.util,
+ org.eclipse.ui.ide;bundle-version="[3.7.0,3.8.0)",
+ org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.200,1.5.0)",
+ org.eclipse.jdt.core;bundle-version="[3.7.1,3.8.0)",
+ org.eclipse.jst.j2ee;bundle-version="[1.1.501,1.2.0)",
+ org.eclipse.jem.util;bundle-version="[2.1.100,2.2.0)",
org.jboss.tools.ws.creation.core,
- org.eclipse.wst.common.frameworks,
- org.eclipse.wst.common.emfworkbench.integration,
+ org.eclipse.wst.common.frameworks;bundle-version="[1.2.101,1.3.0)",
+ org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.2.101,1.3.0)",
org.jboss.tools.common.ui,
- org.eclipse.core.filesystem,
- org.eclipse.wst.common.project.facet.ui,
- org.eclipse.wst.server.core,
- org.eclipse.core.filesystem,
+ org.eclipse.core.filesystem;bundle-version="[1.3.100,1.4.0)",
+ org.eclipse.wst.common.project.facet.ui;bundle-version="[1.4.200,1.5.0)",
+ org.eclipse.wst.server.core;bundle-version="[1.1.103,1.2.0)",
+ org.eclipse.core.filesystem;bundle-version="[1.3.100,1.4.0)",
com.ibm.icu,
- org.eclipse.wst.internet.monitor.core,
- org.eclipse.wst.internet.monitor.ui,
+ org.eclipse.wst.internet.monitor.core;bundle-version="[1.0.505,1.1.0)",
+ org.eclipse.wst.internet.monitor.ui;bundle-version="[1.0.507,1.1.0)",
javax.wsdl;bundle-version="1.6.2",
org.jdom,
- org.eclipse.ui.forms,
- org.eclipse.emf.common,
- org.eclipse.jdt.ui,
- org.eclipse.osgi,
- org.eclipse.jst.ws.annotations.core,
- org.apache.commons.codec,
+ org.eclipse.ui.forms;bundle-version="[3.5.100,3.6.0)",
+ org.eclipse.emf.common;bundle-version="[2.7.0,2.8.0)",
+ org.eclipse.jdt.ui;bundle-version="[3.7.1,3.8.0)",
+ org.eclipse.osgi;bundle-version="[3.7.1,3.8.0)",
+ org.eclipse.jst.ws.annotations.core;bundle-version="[1.1.0,1.2.0)",
+ org.apache.commons.codec;bundle-version="[1.3.0,1.4.0)",
org.apache.commons.discovery;bundle-version="[0.2.0,1.0.0)",
- org.eclipse.xsd
+ org.eclipse.xsd;bundle-version="[2.7.0,2.8.0)"
Bundle-ActivationPolicy: lazy
Export-Package: javax.ws.rs,
javax.ws.rs.core,
14 years, 1 month
JBoss Tools SVN: r38786 - in trunk/runtime/plugins: org.jboss.tools.runtime.core/schema and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2012-02-15 17:45:01 -0500 (Wed, 15 Feb 2012)
New Revision: 38786
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java
Removed:
trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/actions/DownloadRuntimeAction.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeDialog.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeViewerDialog.java
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
Log:
JBIDE-10264 Wizard-ify the project examples
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml 2012-02-15 22:44:23 UTC (rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/plugin.xml 2012-02-15 22:45:01 UTC (rev 38786)
@@ -2,49 +2,4 @@
<?eclipse version="3.4"?>
<plugin>
<extension-point id="runtimeDetectors" name="Runtime Detectors" schema="schema/runtimeDetectors.exsd"/>
- <extension-point id="downloadruntimes" name="Download Runtimes" schema="schema/downloadruntimes.exsd"/>
-
- <extension
- point="org.jboss.tools.runtime.core.downloadruntimes">
- <runtime
- id="org.jboss.tools.runtime.core.as.701"
- name="JBoss AS 7.0.1 Everything (NOT Java EE6 Certified)"
- version="7.0.1.Final"
- size="74MB"
- url="http://download.jboss.org/jbossas/7.0/jboss-as-7.0.1.Final/jboss-as-7.0.1..."/>
- <runtime
- id="org.jboss.tools.runtime.core.as.702"
- name="JBoss AS 7.0.2 Everything (NOT Java EE6 Certified)"
- version="7.0.2.Final"
- size="75MB"
- url="http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-7.0.2..."/>
- <runtime
- id="org.jboss.tools.runtime.core.seam.222"
- name="JBoss Seam 2.2.2.Final"
- version="2.2.2.Final"
- size="113.2MB"
- url="http://sourceforge.net/projects/jboss/files/JBoss%20Seam/2.2.2.Final/jbos..."/>
- <runtime
- id="org.jboss.tools.runtime.core.seam.202"
- name="JBoss Seam 2.0.2.SP1"
- version="2.0.2.SP1"
- size="92.3MB"
- url="http://sourceforge.net/projects/jboss/files/JBoss%20Seam/2.0.2.SP1/jboss-..."/>
-
- <runtime
- id="org.jboss.tools.runtime.core.as.610"
- name="JBoss AS 6.1.0"
- version="6.1.0.Final"
- size="183MB"
- url="http://download.jboss.org/jbossas/6.1/jboss-as-distribution-6.1.0.Final.z..."/>
- <runtime
- id="org.jboss.tools.runtime.core.as.423"
- name="JBoss AS 4.2.3"
- version="4.2.3"
- size="100MB"
- url="http://sourceforge.net/projects/jboss/files/JBoss/JBoss-4.2.3.GA/jboss-4...."/>
-
-
- </extension>
-
</plugin>
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd 2012-02-15 22:44:23 UTC (rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/downloadruntimes.exsd 2012-02-15 22:45:01 UTC (rev 38786)
@@ -1,138 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.jboss.tools.central" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.jboss.tools.central" id="downloadruntimes" name="Download Runtimes"/>
- </appinfo>
- <documentation>
- Downloads a new Runtime
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="runtime" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="runtime">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="version" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="url" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="size" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 3.0.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- <extension
- point="org.jboss.tools.central.downloadruntimes">
-
-</extension>
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- JBoss by Red Hat
- </documentation>
- </annotation>
-
-</schema>
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java 2012-02-15 22:44:23 UTC (rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java 2012-02-15 22:45:01 UTC (rev 38786)
@@ -11,9 +11,7 @@
package org.jboss.tools.runtime.core;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
@@ -29,7 +27,6 @@
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.jboss.tools.runtime.core.model.DownloadRuntime;
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
import org.jboss.tools.runtime.core.model.InvalidRuntimeDetector;
import org.osgi.framework.BundleContext;
@@ -49,8 +46,6 @@
private static final String RUNTIME_DETECTOR_EXTENSION_ID = "org.jboss.tools.runtime.core.runtimeDetectors";
- public static final String DOWNLOAD_RUNTIMES_EXTENSION_ID = "org.jboss.tools.runtime.core.downloadruntimes";
-
private static final String NAME = "name";
private static final String PREFERENCE_ID = "preferenceId";
@@ -74,12 +69,6 @@
private static IEclipsePreferences prefs;
- private static final String VERSION = "version"; //$NON-NLS-1$
- private static final String URL = "url"; //$NON-NLS-1$
-
-
- private Map<String, DownloadRuntime> downloadRuntimes;
-
/**
* The constructor
*/
@@ -237,28 +226,4 @@
return esbDetector;
}
- public Map<String, DownloadRuntime> getDownloadRuntimes() {
- if (downloadRuntimes == null) {
- downloadRuntimes = new HashMap<String, DownloadRuntime>();
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry
- .getExtensionPoint(DOWNLOAD_RUNTIMES_EXTENSION_ID);
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IExtension extension = extensions[i];
- IConfigurationElement[] configurationElements = extension
- .getConfigurationElements();
- for (int j = 0; j < configurationElements.length; j++) {
- IConfigurationElement configurationElement = configurationElements[j];
- String name = configurationElement.getAttribute(NAME);
- String id = configurationElement.getAttribute(ID);
- String version = configurationElement.getAttribute(VERSION);
- String url = configurationElement.getAttribute(URL);
- DownloadRuntime downloadRuntime = new DownloadRuntime(id, name, version, url);
- downloadRuntimes.put(id, downloadRuntime);
- }
- }
- }
- return downloadRuntimes;
- }
}
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java 2012-02-15 22:44:23 UTC (rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java 2012-02-15 22:45:01 UTC (rev 38786)
@@ -1,88 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008-2011 Red Hat, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.runtime.core.model;
-
-/**
- *
- * @author snjeza
- *
- */
-public class DownloadRuntime {
- private String name;
- private String id;
- private String version;
- private String url;
-
- public DownloadRuntime(String id, String name, String version, String url) {
- super();
- this.id = id;
- this.name = name;
- this.version = version;
- this.url = url;
- }
-
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getVersion() {
- return version;
- }
- public void setVersion(String version) {
- this.version = version;
- }
- public String getUrl() {
- return url;
- }
- public void setUrl(String url) {
- this.url = url;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- DownloadRuntime other = (DownloadRuntime) obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "DownloadRuntime [name=" + name + ", id=" + id + ", version="
- + version + ", url=" + url + "]";
- }
-
-}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF 2012-02-15 22:44:23 UTC (rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/META-INF/MANIFEST.MF 2012-02-15 22:45:01 UTC (rev 38786)
@@ -8,13 +8,11 @@
org.eclipse.core.runtime,
org.jboss.tools.runtime.core,
org.eclipse.core.resources,
- org.jboss.tools.project.examples,
org.eclipse.ui.navigator;bundle-version="3.5.100"
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %BundleVendor
Export-Package: org.jboss.tools.runtime.ui,
- org.jboss.tools.runtime.ui.actions,
org.jboss.tools.runtime.ui.dialogs,
org.jboss.tools.runtime.ui.preferences
Added: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java 2012-02-15 22:45:01 UTC (rev 38786)
@@ -0,0 +1,8 @@
+package org.jboss.tools.runtime.ui;
+
+import org.eclipse.swt.widgets.Shell;
+
+public interface IDownloadRuntimes {
+
+ void execute(Shell shell);
+}
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/actions/DownloadRuntimeAction.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/actions/DownloadRuntimeAction.java 2012-02-15 22:44:23 UTC (rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/actions/DownloadRuntimeAction.java 2012-02-15 22:45:01 UTC (rev 38786)
@@ -1,70 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.runtime.ui.actions;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.runtime.core.RuntimeCoreActivator;
-import org.jboss.tools.runtime.core.model.DownloadRuntime;
-import org.jboss.tools.runtime.ui.dialogs.DownloadRuntimeDialog;
-
-/**
- *
- * @author snjeza
- *
- */
-public class DownloadRuntimeAction extends Action {
-
- private String runtimeId;
-
- public DownloadRuntimeAction(String runtimeId) {
- super();
- setRuntimeId(runtimeId);
- }
-
- private void setRuntimeId(String runtimeId) {
- Assert.isNotNull(runtimeId);
- this.runtimeId = runtimeId;
- }
-
- public DownloadRuntimeAction(String text, ImageDescriptor image, String runtimeId) {
- super(text, image);
- setRuntimeId(runtimeId);
- }
-
- public DownloadRuntimeAction(String text, int style, String runtimeId) {
- super(text, style);
- setRuntimeId(runtimeId);
- }
-
- public DownloadRuntimeAction(String text, String runtimeId) {
- super(text);
- setRuntimeId(runtimeId);
- }
-
- @Override
- public void run() {
- Assert.isNotNull(runtimeId);
- // FIXME
- DownloadRuntime runtime = RuntimeCoreActivator.getDefault().getDownloadRuntimes().get(runtimeId);
- DownloadRuntimeDialog dialog = new DownloadRuntimeDialog(getShell(), runtime);
- dialog.open();
- }
-
- private Shell getShell() {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-
- }
-
-}
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeDialog.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeDialog.java 2012-02-15 22:44:23 UTC (rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeDialog.java 2012-02-15 22:45:01 UTC (rev 38786)
@@ -1,442 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.runtime.ui.dialogs;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.fieldassist.ControlDecoration;
-import org.eclipse.jface.fieldassist.FieldDecoration;
-import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.project.examples.ProjectExamplesActivator;
-import org.jboss.tools.project.examples.filetransfer.ECFExamplesTransport;
-import org.jboss.tools.runtime.core.JBossRuntimeLocator;
-import org.jboss.tools.runtime.core.RuntimeCoreActivator;
-import org.jboss.tools.runtime.core.model.DownloadRuntime;
-import org.jboss.tools.runtime.core.model.IRuntimeDetector;
-import org.jboss.tools.runtime.core.model.RuntimePath;
-import org.jboss.tools.runtime.core.model.RuntimeDefinition;
-import org.jboss.tools.runtime.ui.RuntimeUIActivator;
-
-/**
- * @author snjeza
- *
- */
-public class DownloadRuntimeDialog extends Dialog {
-
- private static final String FOLDER_IS_REQUIRED = "This folder is required";
- private static final String FOLDER_IS_NOT_WRITABLE = "This folder does not exist or is not writable";
- private static final String DELETE_ON_EXIT = "deleteOnExit";
- private static final String JAVA_IO_TMPDIR = "java.io.tmpdir";
- private static final String USER_HOME = "user.home";
- private static final String DEFAULT_DIALOG_PATH = "defaultDialogPath";
- private static final String DEFAULT_DESTINATION_PATH = "defaultDestinationPath";
- private IDialogSettings dialogSettings;
- private Button deleteOnExit;
- private Text destinationPathText;
- private Text pathText;
- private DownloadRuntime downloadRuntime;
- private String delete;
- private ControlDecoration decPathError;
- private ControlDecoration decPathReq;
- private ControlDecoration destinationPathError;
- private ControlDecoration destinationPathReq;
-
- public DownloadRuntimeDialog(Shell parentShell, DownloadRuntime downloadRuntime) {
- super(parentShell);
- setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
- | SWT.RESIZE | getDefaultOrientation());
- dialogSettings = RuntimeUIActivator.getDefault().getDialogSettings();
- this.downloadRuntime = downloadRuntime;
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- getShell().setText("Download Runtime '" + downloadRuntime.getName() + "'");
- Composite area = (Composite) super.createDialogArea(parent);
- Composite contents = new Composite(area, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_BOTH);
- //gd.heightHint = 200;
- gd.widthHint = 600;
- contents.setLayoutData(gd);
- contents.setLayout(new GridLayout(1, false));
- applyDialogFont(contents);
- initializeDialogUnits(area);
-
- Composite pathComposite = new Composite(contents, SWT.NONE);
- gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- pathComposite.setLayoutData(gd);
- pathComposite.setLayout(new GridLayout(3, false));
-
-
- Label pathLabel = new Label(pathComposite, SWT.NONE);
- pathLabel.setText("Install folder:");
-
- pathText = new Text(pathComposite, SWT.BORDER);
- gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- pathText.setLayoutData(gd);
- final String defaultPath = getDefaultPath();
- pathText.setText(defaultPath);
- decPathError = addDecoration(pathText, FieldDecorationRegistry.DEC_ERROR, FOLDER_IS_NOT_WRITABLE);
- decPathReq = addDecoration(pathText, FieldDecorationRegistry.DEC_REQUIRED, FOLDER_IS_REQUIRED);
- pathText.addModifyListener(new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- validate();
- }
- });
-
- Button browseButton = new Button(pathComposite, SWT.NONE);
- browseButton.setText("Browse...");
- browseButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- DirectoryDialog dialog = new DirectoryDialog(getShell());
- dialog.setMessage("Select install folder");
- dialog.setFilterPath(pathText.getText());
- final String path = dialog.open();
- if (path == null) {
- return;
- }
- pathText.setText(path);
- }
-
- });
-
- Label destinationLabel = new Label(pathComposite, SWT.NONE);
- destinationLabel.setText("Download folder:");
-
- destinationPathText = new Text(pathComposite, SWT.BORDER);
- gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- destinationPathText.setLayoutData(gd);
- String destinationPath = dialogSettings.get(DEFAULT_DESTINATION_PATH);
- destinationPathError = addDecoration(destinationPathText, FieldDecorationRegistry.DEC_ERROR, FOLDER_IS_NOT_WRITABLE);
- destinationPathReq = addDecoration(destinationPathText, FieldDecorationRegistry.DEC_REQUIRED, FOLDER_IS_REQUIRED);
-
- if (destinationPath == null || destinationPath.isEmpty()) {
- destinationPath=System.getProperty(JAVA_IO_TMPDIR);
- }
- destinationPathText.setText(destinationPath);
- Button browseDestinationButton = new Button(pathComposite, SWT.NONE);
- browseDestinationButton.setText("Browse...");
- browseDestinationButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- DirectoryDialog dialog = new DirectoryDialog(getShell());
- dialog.setMessage("Select download folder");
- dialog.setFilterPath(destinationPathText.getText());
- final String path = dialog.open();
- if (path == null) {
- return;
- }
- destinationPathText.setText(path);
- }
-
- });
-
- destinationPathText.addModifyListener(new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- validate();
- }
- });
-
- deleteOnExit = new Button(pathComposite, SWT.CHECK);
- deleteOnExit.setText("Delete archive after installing");
-
- delete = dialogSettings.get(DELETE_ON_EXIT);
- if (delete == null) {
- delete = "true";
- }
- deleteOnExit.setSelection(new Boolean(delete));
- deleteOnExit.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- delete = new Boolean(deleteOnExit.getSelection()).toString();
- }
-
- });
-
- return area;
- }
-
- private String getDefaultPath() {
- String defaultPath = dialogSettings.get(DEFAULT_DIALOG_PATH);
- if (defaultPath == null || defaultPath.isEmpty()) {
- defaultPath=System.getProperty(USER_HOME);
- }
- return defaultPath;
- }
-
- private void showDecorations() {
- String path = pathText.getText();
- String destination = destinationPathText.getText();
- decPathError.hide();
- decPathReq.hide();
- destinationPathError.hide();
- destinationPathReq.hide();
- if (path.isEmpty()) {
- decPathReq.show();
- }
- if (destination.isEmpty()) {
- destinationPathReq.show();
- }
- boolean pathExists = checkPath(path, decPathError);
- boolean destExists = checkPath(destination, destinationPathError);
- getButton(IDialogConstants.OK_ID).setEnabled(pathExists
- && destExists
- && !path.isEmpty() && !destination.isEmpty());
- decPathError.setShowHover(true);
- }
-
- private boolean checkPath(String path, ControlDecoration dec) {
- if (path.isEmpty()) {
- return true;
- }
- try {
- File file = File.createTempFile("temp", "txt", new File(path));
- file.deleteOnExit();
- file.delete();
- } catch (IOException e) {
- dec.show();
- return false;
- }
- return true;
- }
-
- protected ControlDecoration addDecoration(Control control, String id, String description) {
- final ControlDecoration decPath = new ControlDecoration(control, SWT.TOP
- | SWT.LEFT);
- FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
- FieldDecoration fd = registry.getFieldDecoration(id);
- decPath.setImage(fd.getImage());
- fd.setDescription(description);
-
- decPath.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(
- id).getImage());
-
- decPath.setShowOnlyOnFocus(false);
- decPath.setShowHover(true);
- decPath.setDescriptionText(description);
- return decPath;
- }
-
- protected void validate() {
- getButton(IDialogConstants.OK_ID).setEnabled(true);
- if (pathText.getText().isEmpty()) {
- getButton(IDialogConstants.OK_ID).setEnabled(false);
- }
- if (destinationPathText.getText().isEmpty()) {
- getButton(IDialogConstants.OK_ID).setEnabled(false);
- }
- showDecorations();
- }
-
- @Override
- protected void okPressed() {
- dialogSettings.put(DEFAULT_DESTINATION_PATH,
- destinationPathText.getText());
- dialogSettings.put(DEFAULT_DIALOG_PATH, pathText.getText());
- dialogSettings.put(DELETE_ON_EXIT, delete);
- String selectedDirectory = pathText.getText();
- String destinationDirectory = destinationPathText.getText();
- boolean del = deleteOnExit.getSelection();
- super.okPressed();
- downloadRuntime(selectedDirectory, destinationDirectory, del);
- }
-
- private void downloadRuntime(final String selectedDirectory,
- final String destinationDirectory, final boolean deleteOnExit) {
- final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
- dialog.setBlockOnOpen(false);
- dialog.setCancelable(true);
- dialog.open();
- final IProgressMonitor monitor = dialog.getProgressMonitor();
- monitor.beginTask("Download '" + downloadRuntime.getName() + "' ...", 100);
-
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- downloadAndInstall(selectedDirectory,
- destinationDirectory, deleteOnExit, monitor);
- }
- };
- try {
- dialog.run(true, true, runnable);
- } catch (Exception e) {
- RuntimeCoreActivator.log(e);
- MessageDialog.openError(getActiveShell(), "Error", e.getMessage());
- }
- }
-
- private IStatus downloadAndInstall(String selectedDirectory, String destinationDirectory, boolean deleteOnExit, IProgressMonitor monitor) {
- FileInputStream in = null;
- OutputStream out = null;
- File file = null;
- try {
- URL url = new URL(downloadRuntime.getUrl());
- String name = url.getPath();
- int slashIdx = name.lastIndexOf('/');
- if (slashIdx >= 0)
- name = name.substring(slashIdx + 1);
-
- File destination = new File(destinationDirectory);
- destination.mkdirs();
- file = new File (destination, name);
- int i = 1;
- while (file.exists()) {
- file = new File(destination, name + "(" + i++ + ")");
- }
-
- if (deleteOnExit) {
- file.deleteOnExit();
- }
- out = new BufferedOutputStream(
- new FileOutputStream(file));
-
- IStatus result = ECFExamplesTransport.getInstance().download(file.getName(),
- url.toExternalForm(), out, monitor);
- out.flush();
- out.close();
- if (monitor.isCanceled()) {
- file.deleteOnExit();
- file.delete();
- return Status.CANCEL_STATUS;
- }
- File directory = new File(selectedDirectory);
- directory.mkdirs();
- if (!directory.isDirectory()) {
- RuntimeCoreActivator.getDefault().getLog().log(result);
- MessageDialog.openError(getActiveShell(), "Error", "The '" + directory + "' is not a directory.");
- file.deleteOnExit();
- file.delete();
- return Status.CANCEL_STATUS;
- }
- ProjectExamplesActivator.extractZipFile(file, directory, monitor);
- if (!result.isOK()) {
- RuntimeCoreActivator.getDefault().getLog().log(result);
- String message;
- if (result.getException() != null) {
- message = result.getException().getMessage();
- } else {
- message = result.getMessage();
- }
- MessageDialog.openError(getActiveShell(), "Error", message);
- file.deleteOnExit();
- file.delete();
- return Status.CANCEL_STATUS;
- }
- createRuntimes(selectedDirectory, monitor);
- } catch (IOException e) {
- RuntimeCoreActivator.log(e);
- if (file != null && file.exists()) {
- file.deleteOnExit();
- file.delete();
- }
- MessageDialog.openError(getActiveShell(), "Error", e.getMessage());
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- // ignore
- }
- }
- if (out != null) {
- try {
- out.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- return Status.OK_STATUS;
- }
-
- private Shell getActiveShell() {
- Display display = Display.getDefault();
- if (display != null) {
- return display.getActiveShell();
- }
- return null;
- }
-
- private static void createRuntimes(String directory, IProgressMonitor monitor) {
- JBossRuntimeLocator locator = new JBossRuntimeLocator();
- Set<RuntimePath> runtimePaths = RuntimeUIActivator.getDefault()
- .getRuntimePaths();
- RuntimePath newPath = new RuntimePath(directory);
- runtimePaths.add(newPath);
- for (RuntimePath runtimePath : runtimePaths) {
- List<RuntimeDefinition> serverDefinitions = locator
- .searchForRuntimes(runtimePath.getPath(),
- monitor);
- runtimePath.getServerDefinitions().clear();
- for (RuntimeDefinition serverDefinition : serverDefinitions) {
- serverDefinition.setRuntimePath(runtimePath);
- }
- runtimePath.getServerDefinitions().addAll(serverDefinitions);
- RuntimeUIActivator.getDefault().getRuntimePaths().add(runtimePath);
- RuntimeUIActivator.getDefault().saveRuntimePaths();
- }
- List<RuntimeDefinition> serverDefinitions = RuntimeUIActivator
- .getDefault().getServerDefinitions();
- Set<IRuntimeDetector> detectors = RuntimeCoreActivator
- .getRuntimeDetectors();
- for (IRuntimeDetector detector : detectors) {
- if (detector.isEnabled()) {
- detector.initializeRuntimes(serverDefinitions);
- }
- }
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- showDecorations();
- }
-
-}
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeViewerDialog.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeViewerDialog.java 2012-02-15 22:44:23 UTC (rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/DownloadRuntimeViewerDialog.java 2012-02-15 22:45:01 UTC (rev 38786)
@@ -1,188 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.runtime.ui.dialogs;
-
-import java.util.Map;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.jboss.tools.runtime.core.RuntimeCoreActivator;
-import org.jboss.tools.runtime.core.model.DownloadRuntime;
-
-/**
- * @author snjeza
- *
- */
-public class DownloadRuntimeViewerDialog extends Dialog {
-
- private TableViewer viewer;
- private Map<String, DownloadRuntime> downloadRuntimes;
-
- public DownloadRuntimeViewerDialog(Shell parentShell) {
- super(parentShell);
- setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
- | SWT.RESIZE | getDefaultOrientation());
- // FIXME
- downloadRuntimes = RuntimeCoreActivator.getDefault().getDownloadRuntimes();
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- getShell().setText("Runtimes");
- Composite area = (Composite) super.createDialogArea(parent);
- area.setLayout(new GridLayout());
- Composite contents = new Composite(area, SWT.NONE);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- contents.setLayoutData(gd);
- contents.setLayout(new GridLayout(1, false));
- applyDialogFont(contents);
- initializeDialogUnits(area);
-
- viewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.BORDER);
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.heightHint = 400;
- gd.widthHint = 700;
- viewer.getTable().setLayoutData(gd);
-
- Table table = viewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- table.setFont(parent.getFont());
-
- viewer.setContentProvider(new DownloadRuntimesContentProvider());
-
- //String[] columnHeaders = {"Name", "ID", "Version", "URL"};
- String[] columnHeaders = {"Name", "ID", "Version"};
- for (int i = 0; i < columnHeaders.length; i++) {
- TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
- column.setLabelProvider(new DownloadRuntimesLabelProvider(i));
- column.getColumn().setText(columnHeaders[i]);
- column.getColumn().setResizable(true);
- column.getColumn().setMoveable(true);
- }
-
- ColumnLayoutData[] runtimePathsLayouts= {
- new ColumnWeightData(250,250),
- new ColumnWeightData(200,200),
- new ColumnWeightData(150,150),
-
- };
-
- TableLayout layout = new AutoResizeTableLayout(table);
- for (int i = 0; i < runtimePathsLayouts.length; i++) {
- layout.addColumnData(runtimePathsLayouts[i]);
- }
-
- viewer.setInput(downloadRuntimes);
- if (downloadRuntimes.values().size() > 0) {
- viewer.getTable().select(0);
- }
- viewer.getTable().setLayout(layout);
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- validate();
- }
- });
- return area;
- }
-
- class DownloadRuntimesContentProvider implements IStructuredContentProvider {
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- @Override
- public Object[] getElements(Object inputElement) {
- return downloadRuntimes.values().toArray(new DownloadRuntime[0]);
- }
-
- @Override
- public void dispose() {
-
- }
- }
-
- class DownloadRuntimesLabelProvider extends ColumnLabelProvider {
-
- private int columnIndex;
-
- public DownloadRuntimesLabelProvider(int i) {
- this.columnIndex = i;
- }
-
- public String getText(Object element) {
- if (element instanceof DownloadRuntime) {
- DownloadRuntime downloadRuntime = (DownloadRuntime) element;
- switch (columnIndex) {
- case 0:
- return downloadRuntime.getName();
- case 1:
- return downloadRuntime.getId();
- case 2:
- return downloadRuntime.getVersion();
- case 3:
- return downloadRuntime.getUrl();
- }
- }
- return null;
- }
- }
-
- @Override
- protected void okPressed() {
- ISelection selection = viewer.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- Object object = structuredSelection.getFirstElement();
- if (object instanceof DownloadRuntime) {
- DownloadRuntime downloadRuntime = (DownloadRuntime) object;
- DownloadRuntimeDialog dialog = new DownloadRuntimeDialog(getShell(), downloadRuntime);
- dialog.open();
- }
- }
- super.okPressed();
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- validate();
- }
-
- protected void validate() {
- getButton(IDialogConstants.OK_ID).setEnabled(viewer.getSelection() != null);
- }
-
-}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2012-02-15 22:44:23 UTC (rev 38785)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2012-02-15 22:45:01 UTC (rev 38786)
@@ -16,6 +16,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
@@ -71,12 +72,13 @@
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
import org.jboss.tools.runtime.core.model.RuntimePath;
+import org.jboss.tools.runtime.ui.IDownloadRuntimes;
import org.jboss.tools.runtime.ui.RuntimeUIActivator;
import org.jboss.tools.runtime.ui.dialogs.AutoResizeTableLayout;
-import org.jboss.tools.runtime.ui.dialogs.DownloadRuntimeDialog;
-import org.jboss.tools.runtime.ui.dialogs.DownloadRuntimeViewerDialog;
import org.jboss.tools.runtime.ui.dialogs.EditRuntimePathDialog;
import org.jboss.tools.runtime.ui.dialogs.RuntimePathEditingSupport;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
/**
* @author snjeza
@@ -411,11 +413,12 @@
downloadButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
downloadButton.setText("Download...");
+ final IDownloadRuntimes downloader = getDownloader();
+ downloadButton.setEnabled(downloader != null);
downloadButton.addSelectionListener(new SelectionListener(){
public void widgetSelected(SelectionEvent e) {
- DownloadRuntimeViewerDialog dialog = new DownloadRuntimeViewerDialog(getShell());
- dialog.open();
+ downloader.execute(getShell());
}
public void widgetDefaultSelected(SelectionEvent e) {
@@ -441,6 +444,17 @@
});
}
+ private IDownloadRuntimes getDownloader() {
+ Bundle bundle = Platform.getBundle("org.jboss.tools.project.examples");
+ if (bundle != null) {
+ ServiceReference<IDownloadRuntimes> reference = bundle.getBundleContext().getServiceReference(IDownloadRuntimes.class);
+ if (reference != null) {
+ return bundle.getBundleContext().getService(reference);
+ }
+ }
+ return null;
+ }
+
public void init(IWorkbench workbench) {
runtimePaths = RuntimeUIActivator.getDefault().getRuntimePaths();
runtimeDetectors = RuntimeUIActivator.getDefault().getRuntimeDetectors();
14 years, 1 month
JBoss Tools SVN: r38785 - in trunk/central/plugins/org.jboss.tools.central: META-INF and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2012-02-15 17:44:23 -0500 (Wed, 15 Feb 2012)
New Revision: 38785
Removed:
trunk/central/plugins/org.jboss.tools.central/schema/configurators.exsd
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/configurators/DefaultJBossCentralConfigurator.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/configurators/IJBossCentralConfigurator.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/dialogs/ProjectExamplesDialog.java
Modified:
trunk/central/plugins/org.jboss.tools.central/META-INF/MANIFEST.MF
trunk/central/plugins/org.jboss.tools.central/build.properties
trunk/central/plugins/org.jboss.tools.central/plugin.xml
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossBlogsHandler.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossNewsHandler.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossToolsTwitterHandler.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/SoftwarePage.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshBlogsJob.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshNewsJob.java
Log:
JBIDE-10264 Wizard-ify the project examples
Modified: trunk/central/plugins/org.jboss.tools.central/META-INF/MANIFEST.MF
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/META-INF/MANIFEST.MF 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/META-INF/MANIFEST.MF 2012-02-15 22:44:23 UTC (rev 38785)
@@ -15,9 +15,7 @@
com.sun.syndication;bundle-version="0.9.0",
org.jdom;bundle-version="1.0.0",
org.apache.commons.lang;bundle-version="2.4.0",
- org.jboss.tools.project.examples,
- org.jboss.tools.runtime.core,
- org.jboss.tools.runtime.ui,
+ org.jboss.tools.project.examples;visibility:=reexport,
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",
@@ -33,8 +31,6 @@
.
Export-Package: org.jboss.tools.central,
org.jboss.tools.central.actions,
- org.jboss.tools.central.configurators,
- org.jboss.tools.central.dialogs,
org.jboss.tools.central.editors,
org.jboss.tools.central.editors.xpl,
org.jboss.tools.central.jobs,
Modified: trunk/central/plugins/org.jboss.tools.central/build.properties
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/build.properties 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/build.properties 2012-02-15 22:44:23 UTC (rev 38785)
@@ -5,7 +5,6 @@
.,\
icons/,\
plugin.properties,\
- schema/,\
about.html,\
about.ini,\
about.mappings,\
Modified: trunk/central/plugins/org.jboss.tools.central/plugin.xml
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/plugin.xml 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/plugin.xml 2012-02-15 22:44:23 UTC (rev 38785)
@@ -2,8 +2,6 @@
<?eclipse version="3.4"?>
<plugin>
- <extension-point id="configurators" name="JBoss Central Configurator" schema="schema/configurators.exsd"/>
-
<extension
point="org.eclipse.ui.editors">
<editor
Deleted: trunk/central/plugins/org.jboss.tools.central/schema/configurators.exsd
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/schema/configurators.exsd 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/schema/configurators.exsd 2012-02-15 22:44:23 UTC (rev 38785)
@@ -1,109 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.jboss.tools.central" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.jboss.tools.central" id="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>
Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -14,14 +14,7 @@
import java.net.URL;
import java.util.Dictionary;
import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
@@ -53,11 +46,8 @@
import org.eclipse.ui.menus.CommandContributionItemParameter;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.services.IServiceLocator;
-import org.jboss.tools.central.configurators.DefaultJBossCentralConfigurator;
-import org.jboss.tools.central.configurators.IJBossCentralConfigurator;
import org.jboss.tools.central.editors.JBossCentralEditor;
import org.jboss.tools.central.editors.JBossCentralEditorInput;
-import org.jboss.tools.project.examples.model.ProjectExampleCategory;
import org.jboss.tools.project.examples.model.ProjectExample;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -72,22 +62,20 @@
public static final Object JBOSS_CENTRAL_FAMILY = new Object();
- public static final String JBOSS_DISCOVERY_DIRECTORY = "jboss.discovery.directory.url";
-
- public static final String ICON = "icon";
+// public static final String ICON = "icon";
+//
+// private static final String DESCRIPTION = "description";
+//
+// private static final String TUTORIAL = "tutorial";
+//
+// public static final String CATEGORY_ID = "categoryId";
+//
+// public static final String REFERENCE = "reference";
+//
+// public static final String TYPE = "type";
+//
+// public static final String PRIORITY = "priority";
- private static final String DESCRIPTION = "description";
-
- private static final String TUTORIAL = "tutorial";
-
- public static final String CATEGORY_ID = "categoryId";
-
- public static final String REFERENCE = "reference";
-
- public static final String TYPE = "type";
-
- public static final String PRIORITY = "priority";
-
public static final String ID = "id";
public static final String NAME = "name";
@@ -118,12 +106,8 @@
+ "<span color=\"header\" font=\"header\">Loading...</span>"
+ FORM_END_TAG;
- public static final String TUTORIALS_EXTENSION_ID = "org.jboss.tools.central.tutorials";
+ //public static final String TUTORIALS_EXTENSION_ID = "org.jboss.tools.central.tutorials";
- public static final String CONFIGURATORS_EXTENSION_ID = "org.jboss.tools.central.configurators";
-
- private IJBossCentralConfigurator configurator;
-
// public static final String SEARCH_PROJECT_PAGES = "Search Project Pages";
public static final String SEARCH_THE_COMMUNITY = "Search JBoss Community";
@@ -132,12 +116,8 @@
private BundleContext bundleContext;
- private Map<ProjectExampleCategory, List<ProjectExample>> tutorialCategories;
-
public static final int MAX_FEEDS = 100;
- private static final Object CONFIGURATOR = "configurator";
-
private static final String ORG_ECLIPSE_UI_INTERNAL_INTROVIEW = "org.eclipse.ui.internal.introview";
// The shared instance
@@ -369,38 +349,7 @@
return null;
}
- 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) {
- JBossCentralActivator.log(e);
- continue;
- }
- break;
- }
- }
-
- }
- if (configurator == null) {
- configurator = new DefaultJBossCentralConfigurator();
- }
- }
- return configurator;
- }
-
+
public Image getImage(String imagePath) {
ImageRegistry registry = getImageRegistry();
Image image = registry.get(imagePath);
Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossBlogsHandler.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossBlogsHandler.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossBlogsHandler.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -11,7 +11,7 @@
package org.jboss.tools.central.actions;
-import org.jboss.tools.central.JBossCentralActivator;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
/**
*
@@ -22,7 +22,7 @@
@Override
public String getLocation() {
- return JBossCentralActivator.getDefault().getConfigurator().getBlogsUrl();
+ return ProjectExamplesActivator.getDefault().getConfigurator().getBlogsUrl();
}
}
Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossNewsHandler.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossNewsHandler.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossNewsHandler.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -11,7 +11,7 @@
package org.jboss.tools.central.actions;
-import org.jboss.tools.central.JBossCentralActivator;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
/**
*
@@ -22,7 +22,7 @@
@Override
public String getLocation() {
- return JBossCentralActivator.getDefault().getConfigurator().getNewsUrl();
+ return ProjectExamplesActivator.getDefault().getConfigurator().getNewsUrl();
}
}
Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossToolsTwitterHandler.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossToolsTwitterHandler.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/actions/OpenJBossToolsTwitterHandler.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -11,7 +11,7 @@
package org.jboss.tools.central.actions;
-import org.jboss.tools.central.JBossCentralActivator;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
/**
*
@@ -22,7 +22,7 @@
@Override
public String getLocation() {
- return JBossCentralActivator.getDefault().getConfigurator().getTwitterLink();
+ return ProjectExamplesActivator.getDefault().getConfigurator().getTwitterLink();
}
@Override
Deleted: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/configurators/DefaultJBossCentralConfigurator.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/configurators/DefaultJBossCentralConfigurator.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/configurators/DefaultJBossCentralConfigurator.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -1,89 +0,0 @@
-/*************************************************************************************
- * 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.central.configurators;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.central.JBossCentralActivator;
-
-/**
- *
- * @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/jbosstool...";
-
- // 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}";
-
- private static final String TWITTER_LINK ="http://twitter.com/#!/jbosstools";
-
- private static final String BLOGS_URL = "http://planet.jboss.org/feeds/blogs";
-
- private static final String NEWS_URL = "http://planet.jboss.org/feeds/news";
-
- private Image headerImage;
-
- @Override
- public String[] getMainToolbarCommandIds() {
- return new String[] {"org.jboss.tools.central.openJBossToolsHome",
- "org.jboss.tools.central.favoriteAtEclipseMarketplace",
- "org.jboss.tools.central.preferences"};
- }
-
- @Override
- public String getJBossDiscoveryDirectory() {
- // use commandline override -Djboss.discovery.directory.url
- String directory = System.getProperty(JBossCentralActivator.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;
- }
- 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");
- wizardIds.add("org.jboss.ide.eclipse.as.openshift.express.ui.wizard.createNewApplicationWizard");
- return wizardIds;
- }
-
- @Override
- public Image getHeaderImage() {
- if (headerImage == null) {
- headerImage = JBossCentralActivator.getDefault().getImage("/icons/jboss.png");
- }
- return headerImage;
- }
-}
Deleted: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/configurators/IJBossCentralConfigurator.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/configurators/IJBossCentralConfigurator.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/configurators/IJBossCentralConfigurator.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -1,32 +0,0 @@
-/*************************************************************************************
- * 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.central.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();
-
-}
Deleted: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/dialogs/ProjectExamplesDialog.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/dialogs/ProjectExamplesDialog.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/dialogs/ProjectExamplesDialog.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -1,516 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.central.dialogs;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.lang.StringEscapeUtils;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.operation.ModalContext;
-import org.eclipse.jface.window.ToolTip;
-import org.eclipse.jface.wizard.ProgressMonitorPart;
-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.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.FormDialog;
-import org.eclipse.ui.forms.HyperlinkSettings;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.FormText;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.jboss.tools.central.JBossCentralActivator;
-import org.jboss.tools.central.actions.JBossRuntimeDetectionPreferencesHandler;
-import org.jboss.tools.central.editors.DescriptionToolTip;
-import org.jboss.tools.project.examples.ProjectExamplesActivator;
-import org.jboss.tools.project.examples.model.ProjectExample;
-import org.jboss.tools.project.examples.model.ProjectFix;
-import org.jboss.tools.runtime.core.RuntimeCoreActivator;
-import org.jboss.tools.runtime.core.model.DownloadRuntime;
-import org.jboss.tools.runtime.ui.actions.DownloadRuntimeAction;
-
-/**
- * @author snjeza
- *
- */
-public class ProjectExamplesDialog extends FormDialog implements IRunnableContext {
-
- private ProjectExample tutorial;
- private FormToolkit toolkit;
- private ScrolledForm form;
- private Composite fixesComposite;
- private Section reqSection;
- private ProgressMonitorPart fProgressMonitorPart;
- private Control fLastControl;
- private Set<Button> controls = new HashSet<Button>();
-
- public ProjectExamplesDialog(Shell parentShell, ProjectExample project) {
- super(parentShell);
- setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
- | SWT.RESIZE | getDefaultOrientation());
- this.tutorial = project;
- //setHelpAvailable(false);
- }
-
- @Override
- protected void createFormContent(IManagedForm mform) {
- mform.getForm().setText(tutorial.getDescription());
- form = mform.getForm();
- toolkit = mform.getToolkit();
- toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_HOVER);
- form.getBody().setLayout(new GridLayout());
- form.setText(tutorial.getShortDescription());
- Section descSection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.EXPANDED);
- descSection.setText("Description");
- descSection.setLayout(new GridLayout());
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- descSection.setLayoutData(gd);
- Text text = new Text(descSection, SWT.READ_ONLY | SWT.WRAP);
- text.setText(JBossCentralActivator.getDefault().getDescription(tutorial));
- toolkit.adapt(text, false, false);
- gd = new GridData(GridData.FILL, GridData.FILL, false, false);
- text.setLayoutData(gd);
- descSection.setClient(text);
-
- reqSection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED);
- reqSection.setText("Requirements");
- reqSection.setLayout(new GridLayout());
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- reqSection.setLayoutData(gd);
-
- fixesComposite = toolkit.createComposite(reqSection);
- fixesComposite.setLayout(new GridLayout(3, false));
- fixesComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- reqSection.setClient(fixesComposite);
-
- refreshFixes();
-
- mform.getForm().setBackgroundImage(null);
- mform.getToolkit().decorateFormHeading(mform.getForm().getForm());
- mform.getForm().setImage(
- JBossCentralActivator.getDefault().getImage(
- "/icons/examples_wiz.gif"));
- getShell().setText("Project Example");
- form.getBody().pack();
- }
-
- protected void refreshFixes() {
- controls.clear();
- addButtons();
-
- List<ProjectFix> fixes = tutorial.getFixes();
- List<ProjectFix> unsatisfiedFixes = new ArrayList<ProjectFix>();
- tutorial.setUnsatisfiedFixes(unsatisfiedFixes);
- for (ProjectFix fix:fixes) {
- if (!ProjectExamplesActivator.canFix(tutorial, fix)) {
- unsatisfiedFixes.add(fix);
- }
- }
- fixes = tutorial.getUnsatisfiedFixes();
- disposeChildren(fixesComposite);
- reqSection.setVisible(fixes.size() > 0);
- if (fixes.size() > 0) {
- for (ProjectFix projectFix : fixes) {
- if (ProjectFix.WTP_RUNTIME.equals(projectFix.getType())
- || ProjectFix.SEAM_RUNTIME.equals(projectFix.getType())) {
- addDescription(projectFix);
- addRuntimeFixActions(projectFix);
- }
- }
- Set<String> connectorIds = new HashSet<String>();
- boolean havePluginFix = false;
- for (ProjectFix projectFix : fixes) {
- if (ProjectFix.PLUGIN_TYPE.equals(projectFix.getType())) {
- if (havePluginFix) {
- new Label(fixesComposite, SWT.NONE);
- new Label(fixesComposite, SWT.NONE);
- }
- addDescription(projectFix);
- havePluginFix = true;
- String connectorId = projectFix.getProperties().get(ProjectFix.CONNECTOR_ID);
- if (connectorId != null) {
- String[] ids = connectorId.split(",");
- for (String id:ids) {
- if (id != null && !id.trim().isEmpty()) {
- connectorIds.add(id.trim());
- }
- }
- }
- }
- }
- if (havePluginFix) {
- addPluginFixActions(connectorIds);
- } else {
- new Label(fixesComposite, SWT.NONE);
- new Label(fixesComposite, SWT.NONE);
- }
- }
- }
-
- protected void addButtons() {
- Button cancelButton = getButton(IDialogConstants.CANCEL_ID);
- if (getButton(IDialogConstants.CANCEL_ID) != null) {
- controls.add(cancelButton);
- controls.add(getButton(IDialogConstants.OK_ID));
- }
- }
-
- private void disposeChildren(Composite composite) {
- Control[] children = composite.getChildren();
- for (Control child : children) {
- if (child instanceof Composite) {
- disposeChildren((Composite) child);
- child.dispose();
- } else {
- child.dispose();
- }
- }
- }
-
- private void addDescription(ProjectFix projectFix) {
- FormText fixDescriptionText = toolkit.createFormText(fixesComposite, true);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- fixDescriptionText.setLayoutData(gd);
- StringBuffer buffer = new StringBuffer();
- buffer.append(JBossCentralActivator.FORM_START_TAG);
- buffer.append("<img href=\"image\"/> ");
- String description = projectFix.getProperties().get(ProjectFix.DESCRIPTION);
- description = StringEscapeUtils.escapeHtml(description);
- buffer.append(description);
- buffer.append(JBossCentralActivator.FORM_END_TAG);
- fixDescriptionText.setText(buffer.toString(), true, false);
- if (ProjectFix.WTP_RUNTIME.equals(projectFix.getType())) {
- fixDescriptionText.setImage("image", JBossCentralActivator.getDefault().getImage("/icons/wtp_server.gif"));
- } else if (ProjectFix.SEAM_RUNTIME.equals(projectFix.getType())) {
- fixDescriptionText.setImage("image", JBossCentralActivator.getDefault().getImage("/icons/seam16.png"));
- } if (ProjectFix.PLUGIN_TYPE.equals(projectFix.getType())) {
- fixDescriptionText.setImage("image", JBossCentralActivator.getDefault().getImage("/icons/software.png"));
- }
- }
-
- protected void addRuntimeFixActions(ProjectFix projectFix) {
- Button install = toolkit.createButton(fixesComposite, "Install", SWT.PUSH);
- GridData gd = new GridData(SWT.FILL, SWT.END, false, false);
- install.setLayoutData(gd);
- ToolTip tooltip = new DescriptionToolTip(install, "JBoss Runtime Detection");
- tooltip.activate();
- //install.setImage(JBossCentralActivator.getDefault().getImage("/icons/search_local.png"));
- install.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- new JBossRuntimeDetectionPreferencesHandler().execute(new ExecutionEvent());
- } catch (ExecutionException e1) {
- JBossCentralActivator.log(e1);
- }
- refresh();
- }
- });
- controls.add(install);
- final String downloadId = projectFix.getProperties().get(ProjectFix.DOWNLOAD_ID);
- boolean haveDownloadId = false;
- if (downloadId != null) {
- DownloadRuntime downloadRuntime = RuntimeCoreActivator.getDefault().getDownloadRuntimes().get(downloadId);
- if (downloadRuntime != null) {
- haveDownloadId = true;
- Button download = toolkit.createButton(fixesComposite, "Download and Install...", SWT.PUSH);
- gd = new GridData(SWT.FILL, SWT.END, false, false);
- download.setLayoutData(gd);
- ToolTip tip = new DescriptionToolTip(download, "Download and install " + downloadRuntime.getName());
- tip.activate();
- //download.setImage(JBossCentralActivator.getDefault().getImage("/icons/repository-submit.gif"));
- controls.add(download);
- download.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- new DownloadRuntimeAction(downloadId).run();
- refresh();
- }
- });
-
- }
- }
- if (!haveDownloadId) {
- new Label(fixesComposite, SWT.NONE);
- }
- }
-
- protected void addPluginFixActions(final Set<String> connectorIds) {
- if (connectorIds.size() > 0) {
- Button install = toolkit.createButton(fixesComposite, "Install", SWT.PUSH);
- ToolTip tooltip = new DescriptionToolTip(install, "Install required feature(s)");
- tooltip.activate();
- //install.setImage(JBossCentralActivator.getDefault().getImage("/icons/software.png"));
- install.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- install(connectorIds);
- } catch (Exception e1) {
- // FIXME
- JBossCentralActivator.log(e1);
- }
- refresh();
- }
- });
- controls.add(install);
- }
- Button p2install = toolkit.createButton(fixesComposite, "Install New Software", SWT.PUSH);
- ToolTip tip = new DescriptionToolTip(p2install, "P2 Install New Software");
- tip.activate();
- //p2install.setImage(JBossCentralActivator.getDefault().getImage("/icons/update.gif"));
-
- p2install.addSelectionListener(new SelectionAdapter() {
-
- @Override
- 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());
- }
- catch (Exception e1) {
- JBossCentralActivator.log(e1);
- }
- refresh();
- }
- });
- controls.add(p2install);
- if (connectorIds.size() == 0) {
- new Label(fixesComposite, SWT.NONE);
- }
- }
-
- 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(JBossCentralActivator.getDefault().getConfigurator().getJBossDiscoveryDirectory());
- connectorDiscoveries[0].getDiscoveryStrategies().add(remoteDiscoveryStrategy);
-
- connectorDiscoveries[0].setEnvironment(JBossCentralActivator.getEnvironment());
- connectorDiscoveries[0].setVerifyUpdateSiteAvailability(true);
- results[0] = connectorDiscoveries[0].performDiscovery(monitor);
- if (monitor.isCanceled()) {
- results[0] = Status.CANCEL_STATUS;
- }
- }
- };
- 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, ProjectExamplesDialog.this);
- } 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;
- }
- }
-
- }
-
- @Override
- public void run(boolean fork, boolean cancelable,
- IRunnableWithProgress runnable) throws InvocationTargetException,
- InterruptedException {
- //ModalContext.run(runnable, cancelable, monitor, getDisplay());
- if (getShell() != null && getShell().isVisible()) {
- // Save focus control
- fLastControl = getShell().getDisplay().getFocusControl();
- if (fLastControl != null && fLastControl.getShell() != getShell()) {
- fLastControl = null;
- }
- // Attach the progress monitor part to the cancel button
- fProgressMonitorPart.attachToCancelComponent(null);
- fProgressMonitorPart.getParent().setVisible(true);
-
- try {
- updateControls(false);
- ModalContext.run(runnable, fork, fProgressMonitorPart, getShell().getDisplay());
- }
- finally {
- updateControls(true);
- if (getShell() != null) {
- fProgressMonitorPart.getParent().setVisible(false);
- fProgressMonitorPart.removeFromCancelComponent(null);
- if (fLastControl != null) {
- fLastControl.setFocus();
- }
- }
- }
- }
- else {
- PlatformUI.getWorkbench().getProgressService().run(fork, cancelable, runnable);
- }
- }
-
- private void updateControls(boolean enabled) {
- for (Button control:controls) {
- control.setEnabled(enabled);
- }
- }
-
- protected Display getDisplay() {
- Display display = Display.getCurrent();
- if (display == null) {
- display = Display.getDefault();
- }
- return display;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createButtonBar(org.eclipse.swt.widgets.Composite)
- */
- protected Control createButtonBar(Composite parent) {
- Font font = parent.getFont();
- Composite composite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.marginLeft = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- composite.setFont(font);
- Label sep = new Label(composite, SWT.HORIZONTAL|SWT.SEPARATOR);
- sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Composite buttonComposite = new Composite(composite, SWT.NULL);
- layout = new GridLayout();
- if (isHelpAvailable()) {
- layout.numColumns = 3;
- } else {
- layout.numColumns = 2;
- }
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.marginLeft = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- buttonComposite.setLayout(layout);
- buttonComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- buttonComposite.setFont(font);
-
- if (isHelpAvailable()) {
- createHelpControl(buttonComposite);
- }
- Composite monitorComposite = new Composite(buttonComposite, SWT.NULL);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.numColumns = 2;
- monitorComposite.setLayout(layout);
- monitorComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout pmLayout = new GridLayout();
- fProgressMonitorPart= new ProgressMonitorPart(monitorComposite, pmLayout, true);
- fProgressMonitorPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fProgressMonitorPart.setFont(font);
- monitorComposite.setVisible(false);
-
- boolean helpAvailable = isHelpAvailable();
- setHelpAvailable(false);
- super.createButtonBar(buttonComposite);
- Control[] children = buttonComposite.getChildren();
- for (Control child:children) {
- if (child instanceof Label) {
- child.setVisible(false);
- child.dispose();
- }
- }
- setHelpAvailable(helpAvailable);
- return composite;
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, "Start",
- true);
- createButton(parent, IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL, false);
- addButtons();
- }
-
- protected void refresh() {
- if (form == null || form.isDisposed()) {
- return;
- }
- refreshFixes();
- fixesComposite.pack();
- form.reflow(true);
- form.redraw();
- form.layout(true, true);
- getShell().pack();
- }
-
- @Override
- protected void okPressed() {
- super.okPressed();
- ProjectExamplesActivator.importProjectExamples(Arrays.asList(tutorial), true);
- }
-
-}
Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -93,14 +93,15 @@
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.tools.central.JBossCentralActivator;
-import org.jboss.tools.central.dialogs.ProjectExamplesDialog;
import org.jboss.tools.central.jobs.AbstractRefreshJob;
import org.jboss.tools.central.jobs.RefreshBlogsJob;
import org.jboss.tools.central.jobs.RefreshNewsJob;
import org.jboss.tools.central.jobs.RefreshTutorialsJob;
import org.jboss.tools.central.model.FeedsEntry;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
import org.jboss.tools.project.examples.model.ProjectExample;
import org.jboss.tools.project.examples.model.ProjectExampleCategory;
+import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard2;
import org.osgi.framework.Bundle;
/**
@@ -552,7 +553,7 @@
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint("org.eclipse.ui.newWizards");
IExtension[] extensions = extensionPoint.getExtensions();
- List<String> wizardIDs = JBossCentralActivator.getDefault().getConfigurator().getWizardIds();
+ List<String> wizardIDs = ProjectExamplesActivator.getDefault().getConfigurator().getWizardIds();
List<String> createdIDs = new ArrayList<String>();
for (IExtension extension : extensions) {
@@ -985,8 +986,11 @@
public void linkActivated(HyperlinkEvent e) {
Object object = e.data;
if (object instanceof String) {
- ProjectExamplesDialog dialog = new ProjectExamplesDialog(getSite().getShell(), tutorial);
+ NewProjectExamplesWizard2 wizard = new NewProjectExamplesWizard2(tutorial);
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
dialog.open();
+ //ProjectExamplesDialog dialog = new ProjectExamplesDialog(getSite().getShell(), tutorial);
+ //dialog.open();
refreshTutorials();
}
}
Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -47,6 +47,7 @@
import org.jboss.tools.central.JBossCentralActivator;
import org.jboss.tools.central.actions.OpenJBossBlogsHandler;
import org.jboss.tools.central.editors.xpl.TextSearchControl;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
/**
*
@@ -137,7 +138,7 @@
}
setPageImage(index, gettingStartedImage);
- if (JBossCentralActivator.getDefault().getConfigurator()
+ if (ProjectExamplesActivator.getDefault().getConfigurator()
.getJBossDiscoveryDirectory() != null) {
softwarePage = new SoftwarePage(this);
index = addPage(softwarePage);
@@ -174,7 +175,7 @@
};
toolbar.add(searchControl);
toolbar.add(new GroupMarker(COMMANDS_GROUP));
- String[] commandIds = JBossCentralActivator.getDefault()
+ String[] commandIds = ProjectExamplesActivator.getDefault()
.getConfigurator().getMainToolbarCommandIds();
for (String commandId : commandIds) {
CommandContributionItem item = JBossCentralActivator
@@ -323,7 +324,7 @@
}
private Image getHeaderImage() {
- return JBossCentralActivator.getDefault().getConfigurator()
+ return ProjectExamplesActivator.getDefault().getConfigurator()
.getHeaderImage();
}
Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/SoftwarePage.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/SoftwarePage.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/SoftwarePage.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -44,7 +44,6 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
@@ -57,6 +56,7 @@
import org.jboss.tools.central.JBossCentralActivator;
import org.jboss.tools.central.editors.xpl.DiscoveryViewer;
import org.jboss.tools.central.jobs.RefreshDiscoveryJob;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
/**
*
@@ -131,7 +131,7 @@
discoveryViewer = new DiscoveryViewer(getSite(), this);
discoveryViewer.setShowConnectorDescriptorKindFilter(false);
discoveryViewer.setShowInstalledFilterEnabled(true);
- discoveryViewer.setDirectoryUrl(JBossCentralActivator.getDefault().getConfigurator().getJBossDiscoveryDirectory());
+ discoveryViewer.setDirectoryUrl(ProjectExamplesActivator.getDefault().getConfigurator().getJBossDiscoveryDirectory());
discoveryViewer.createControl(pageBook);
discoveryViewer.setEnvironment(getEnvironment());
discoveryViewer.addFilter(new ViewerFilter() {
Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshBlogsJob.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshBlogsJob.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshBlogsJob.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -14,6 +14,7 @@
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.central.JBossCentralActivator;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
/**
*
@@ -26,7 +27,7 @@
public static RefreshBlogsJob INSTANCE = new RefreshBlogsJob();
private RefreshBlogsJob() {
- super("Refreshing JBoss Blogs...", JBossCentralActivator.getDefault().getConfigurator().getBlogsUrl());
+ super("Refreshing JBoss Blogs...", ProjectExamplesActivator.getDefault().getConfigurator().getBlogsUrl());
}
@Override
Modified: trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshNewsJob.java
===================================================================
--- trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshNewsJob.java 2012-02-15 22:40:09 UTC (rev 38784)
+++ trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshNewsJob.java 2012-02-15 22:44:23 UTC (rev 38785)
@@ -14,6 +14,7 @@
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.central.JBossCentralActivator;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
/**
*
@@ -27,7 +28,7 @@
private RefreshNewsJob() {
- super("Refreshing JBoss News...", JBossCentralActivator.getDefault().getConfigurator().getNewsUrl());
+ super("Refreshing JBoss News...", ProjectExamplesActivator.getDefault().getConfigurator().getNewsUrl());
}
@Override
14 years, 1 month
JBoss Tools SVN: r38784 - in trunk: examples/plugins/org.jboss.tools.project.examples and 18 other directories.
by jbosstools-commits@lists.jboss.org
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-category-3...</url>
</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/jboss-as-7.0.1..."/>
+ <runtime
+ id="org.jboss.tools.runtime.core.as.702"
+ name="JBoss AS 7.0.2 Everything (NOT Java EE6 Certified)"
+ version="7.0.2.Final"
+ size="75MB"
+ url="http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-7.0.2..."/>
+ <runtime
+ id="org.jboss.tools.runtime.core.seam.222"
+ name="JBoss Seam 2.2.2.Final"
+ version="2.2.2.Final"
+ size="113.2MB"
+ url="http://sourceforge.net/projects/jboss/files/JBoss%20Seam/2.2.2.Final/jbos..."/>
+ <runtime
+ id="org.jboss.tools.runtime.core.seam.202"
+ name="JBoss Seam 2.0.2.SP1"
+ version="2.0.2.SP1"
+ size="92.3MB"
+ url="http://sourceforge.net/projects/jboss/files/JBoss%20Seam/2.0.2.SP1/jboss-..."/>
+
+ <runtime
+ id="org.jboss.tools.runtime.core.as.610"
+ name="JBoss AS 6.1.0"
+ version="6.1.0.Final"
+ size="183MB"
+ url="http://download.jboss.org/jbossas/6.1/jboss-as-distribution-6.1.0.Final.z..."/>
+ <runtime
+ id="org.jboss.tools.runtime.core.as.423"
+ name="JBoss AS 4.2.3"
+ version="4.2.3"
+ size="100MB"
+ url="http://sourceforge.net/projects/jboss/files/JBoss/JBoss-4.2.3.GA/jboss-4...."/>
+
+ </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/jbosstool..."; //$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;
}
14 years, 1 month
JBoss Tools SVN: r38783 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-02-15 17:20:03 -0500 (Wed, 15 Feb 2012)
New Revision: 38783
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
Log:
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-02-15 22:02:30 UTC (rev 38782)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-02-15 22:20:03 UTC (rev 38783)
@@ -130,9 +130,6 @@
}
}
- /**
- * @return the existingApplications
- */
public List<IApplication> getExistingApplications() {
return existingApplications;
}
@@ -151,8 +148,9 @@
* the existingApplications to set
*/
public void setExistingApplications(List<IApplication> existingApplications) {
- firePropertyChange(PROPERTY_EXISTING_APPLICATIONS, this.existingApplications,
- this.existingApplications = existingApplications);
+ firePropertyChange(PROPERTY_EXISTING_APPLICATIONS
+ , this.existingApplications
+ , this.existingApplications = existingApplications);
}
public void loadCartridges() throws OpenShiftException {
@@ -186,8 +184,6 @@
}
public List<IEmbeddableCartridge> loadEmbeddableCartridges() throws OpenShiftException {
- // List<IEmbeddableCartridge> cartridges =
- // OpenShiftUIActivator.getDefault().getUser().getEmbeddableCartridges();
List<IEmbeddableCartridge> cartridges = getUser().getEmbeddableCartridges();
setEmbeddableCartridges(cartridges);
return cartridges;
14 years, 1 month
JBoss Tools SVN: r38782 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-02-15 17:02:30 -0500 (Wed, 15 Feb 2012)
New Revision: 38782
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java
Log:
[JBIDE-10917] making sure that the GitCloningWizardPage gets notified of changes in ApplicationName (was: initial invalid state caused by empty application name was not updated by changes in application name on ApplicationConfigurationWizardPage)
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-02-15 21:55:53 UTC (rev 38781)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-02-15 22:02:30 UTC (rev 38782)
@@ -61,10 +61,6 @@
return wizardModel.isNewProject();
}
-// public void refreshApplicationName() {
-// firePropertyChange(PROPERTY_APPLICATION_NAME, null, wizardModel.getApplicationName());
-// }
-
public void setApplicationName(String name) {
firePropertyChange(PROPERTY_APPLICATION_NAME
, wizardModel.getApplicationName()
14 years, 1 month
JBoss Tools SVN: r38781 - in trunk: deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-02-15 16:55:53 -0500 (Wed, 15 Feb 2012)
New Revision: 38781
Added:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/IObservablePojo.java
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/ObservablePojo.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
Log:
[JBIDE-10917] making sure that the GitCloningWizardPage gets notified of changes in ApplicationName (was: initial invalid state caused by empty application name was not updated by changes in application name on ApplicationConfigurationWizardPage)
Added: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/IObservablePojo.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/IObservablePojo.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/IObservablePojo.java 2012-02-15 21:55:53 UTC (rev 38781)
@@ -0,0 +1,20 @@
+package org.jboss.tools.common.databinding;
+
+import java.beans.PropertyChangeListener;
+
+public interface IObservablePojo {
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
+
+ public void addPropertyChangeListener(PropertyChangeListener listener);
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
+
+ public void removePropertyChangeListener(
+ PropertyChangeListener listener);
+
+ public void removeAllPropertyChangeListeners();
+
+ public void dispose();
+
+}
\ No newline at end of file
Property changes on: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/IObservablePojo.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/ObservablePojo.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/ObservablePojo.java 2012-02-15 21:25:24 UTC (rev 38780)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/ObservablePojo.java 2012-02-15 21:55:53 UTC (rev 38781)
@@ -17,7 +17,7 @@
* A POJO base class that may notify observers on behalf of
* {@link PropertyChangeSupport}
*/
-public abstract class ObservablePojo {
+public abstract class ObservablePojo implements IObservablePojo {
private PropertyChangeSupport propertyChangeSupport;
@@ -33,27 +33,38 @@
propertyChangeSupport.fireIndexedPropertyChange(propertyName, index, oldValue, newValue);
}
+ @Override
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
if (!contains(listener)) {
propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
}
}
+ @Override
public void addPropertyChangeListener(PropertyChangeListener listener) {
if (!contains(listener)) {
propertyChangeSupport.addPropertyChangeListener(listener);
}
}
+ @Override
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
}
+ @Override
public void removePropertyChangeListener(
PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(listener);
}
-
+
+ @Override
+ public void removeAllPropertyChangeListeners() {
+ for (PropertyChangeListener listener : getPropertyChangeSupport().getPropertyChangeListeners()) {
+ getPropertyChangeSupport().removePropertyChangeListener(listener);
+ }
+ }
+
protected boolean contains(PropertyChangeListener listener) {
boolean contains = false;
for (PropertyChangeListener registeredListener : propertyChangeSupport.getPropertyChangeListeners()) {
@@ -68,4 +79,9 @@
protected PropertyChangeSupport getPropertyChangeSupport() {
return propertyChangeSupport;
}
+
+ @Override
+ public void dispose() {
+ removeAllPropertyChangeListeners();
+ }
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2012-02-15 21:25:24 UTC (rev 38780)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2012-02-15 21:55:53 UTC (rev 38781)
@@ -601,8 +601,14 @@
return null;
}
- public void dispose() throws DeltaCloudException {
- passwordStore.remove();
+ @Override
+ public void dispose() {
+ super.dispose();
+ try {
+ passwordStore.remove();
+ } catch(DeltaCloudException e) {
+ Activator.log(e);
+ }
}
public String toString() {
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-02-15 21:25:24 UTC (rev 38780)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-02-15 21:55:53 UTC (rev 38781)
@@ -123,7 +123,11 @@
UIUtils.focusOnSelection(useDefaultRepoPathButton, repoPathText);
dbc.addValidationStatusProvider(
- new RepoPathValidationStatusProvider(isDefaultRepoObservable, repoPathObservable));
+ new RepoPathValidationStatusProvider(
+ isDefaultRepoObservable
+ , repoPathObservable
+ , BeanProperties.value(GitCloningSettingsWizardPageModel.PROPERTY_APPLICATION_NAME).observe(
+ pageModel)));
// Remote Name Management
useDefaultRemoteNameButton = new Button(cloneGroup, SWT.CHECK);
@@ -219,6 +223,7 @@
// allow to enable a proj only for as7 openshift applications
// pageModel.resetRepositoryPath();
pageModel.resetRemoteName();
+// pageModel.refreshApplicationName();
enableWidgets(pageModel.isNewProject());
}
@@ -243,23 +248,25 @@
private final IObservableValue isDefaultRepoPathObservable;
private final IObservableValue repoPathObservable;
+ private IObservableValue applicationNameObservable;
public RepoPathValidationStatusProvider(IObservableValue isDefaultRepoPathObservable,
- IObservableValue repoPathObservable) {
+ IObservableValue repoPathObservable, IObservableValue applicationNameObservable) {
this.isDefaultRepoPathObservable = isDefaultRepoPathObservable;
this.repoPathObservable = repoPathObservable;
+ this.applicationNameObservable = applicationNameObservable;
}
@Override
protected IStatus validate() {
Boolean isDefaultRepoPath = (Boolean) isDefaultRepoPathObservable.getValue();
String repoPath = (String) repoPathObservable.getValue();
+ String applicationName = (String) applicationNameObservable.getValue();
// skip the validation if the user wants to create a new project.
// The
// name and state of the existing project do
// not matter...
- String applicationName = pageModel.getApplicationName();
if (applicationName == null
|| applicationName.length() == 0) {
return OpenShiftUIActivator
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-02-15 21:25:24 UTC (rev 38780)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-02-15 21:55:53 UTC (rev 38781)
@@ -13,6 +13,9 @@
import static org.jboss.tools.openshift.express.internal.ui.wizard.IOpenShiftExpressWizardModel.EXISTING_PROJECT_REMOTE_NAME_DEFAULT;
import static org.jboss.tools.openshift.express.internal.ui.wizard.IOpenShiftExpressWizardModel.NEW_PROJECT_REMOTE_NAME_DEFAULT;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
@@ -28,6 +31,7 @@
*/
public class GitCloningSettingsWizardPageModel extends ObservableUIPojo {
+ public static final String PROPERTY_APPLICATION_NAME = "applicationName";
public static final String PROPERTY_REPO_PATH = "repositoryPath";
public static final String PROPERTY_REMOTE_NAME = "remoteName";
public static final String PROPERTY_USE_DEFAULT_REPO_PATH = "useDefaultRepoPath";
@@ -39,13 +43,34 @@
public GitCloningSettingsWizardPageModel(IOpenShiftExpressWizardModel wizardModel) {
this.wizardModel = wizardModel;
+ wizardModel.addPropertyChangeListener(IOpenShiftExpressWizardModel.APPLICATION_NAME, onWizardApplicationNameChanged());
setRepositoryPath(getDefaultRepositoryPath());
}
+ private PropertyChangeListener onWizardApplicationNameChanged() {
+ return new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_APPLICATION_NAME, evt.getOldValue(), evt.getNewValue());
+ }
+ };
+ }
+
public boolean isNewProject() {
return wizardModel.isNewProject();
}
+// public void refreshApplicationName() {
+// firePropertyChange(PROPERTY_APPLICATION_NAME, null, wizardModel.getApplicationName());
+// }
+
+ public void setApplicationName(String name) {
+ firePropertyChange(PROPERTY_APPLICATION_NAME
+ , wizardModel.getApplicationName()
+ , wizardModel.setApplicationName(name));
+ }
+
public String getApplicationName() {
return wizardModel.getApplicationName();
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java 2012-02-15 21:25:24 UTC (rev 38780)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java 2012-02-15 21:55:53 UTC (rev 38781)
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServerType;
+import org.jboss.tools.common.databinding.IObservablePojo;
import org.jboss.tools.openshift.egit.ui.util.EGitUIUtils;
import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
@@ -32,7 +33,7 @@
/**
* @author André Dietisheim
*/
-public interface IOpenShiftExpressWizardModel extends IUserAwareModel {
+public interface IOpenShiftExpressWizardModel extends IUserAwareModel, IObservablePojo {
public static final String NEW_PROJECT = "enableProject";
public static final String USER = "user";
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-02-15 21:25:24 UTC (rev 38780)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-02-15 21:55:53 UTC (rev 38781)
@@ -313,4 +313,9 @@
}
}
+ @Override
+ public void dispose() {
+ wizardModel.dispose();
+ }
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-02-15 21:25:24 UTC (rev 38780)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-02-15 21:55:53 UTC (rev 38781)
@@ -397,7 +397,8 @@
@Override
public String setApplicationName(String applicationName) {
- return (String) dataModel.put(APPLICATION_NAME, applicationName);
+ firePropertyChange(APPLICATION_NAME, getApplicationName(), dataModel.put(APPLICATION_NAME, applicationName));
+ return applicationName;
}
protected void setApplicationName(IApplication application) {
14 years, 1 month