Author: akazakov
Date: 2009-04-14 07:30:02 -0400 (Tue, 14 Apr 2009)
New Revision: 14734
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4135 Fixed
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2009-04-14
10:33:00 UTC (rev 14733)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2009-04-14
11:30:02 UTC (rev 14734)
@@ -86,6 +86,27 @@
}
/**
+ * @return the latest version of installed Seam runtimes. If there are a few runtimes
with the same version
+ * then the default one will be returned.
+ */
+ public SeamRuntime getLatestSeamRuntime() {
+ SeamVersion latestVersion = SeamVersion.SEAM_1_2;
+ for (SeamRuntime runtime : runtimes.values()) {
+ if(runtime.getVersion().compareTo(latestVersion)>=0) {
+ latestVersion = runtime.getVersion();
+ }
+ }
+ SeamRuntime runtime = getDefaultRuntime(latestVersion);
+ if(runtime==null) {
+ SeamRuntime[] runtimes = getRuntimes(latestVersion);
+ if(runtimes.length>0) {
+ runtime = runtimes[0];
+ }
+ }
+ return runtime;
+ }
+
+ /**
* Return array of SeamRuntimes that is compatible with given version
*
* @param version
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java 2009-04-14
10:33:00 UTC (rev 14733)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java 2009-04-14
11:30:02 UTC (rev 14734)
@@ -54,7 +54,7 @@
.node(DefaultScope.SCOPE)
.node(SeamCorePlugin.PLUGIN_ID);
- node.put(SeamProjectPreferences.SEAM_CONFIG_TEMPLATE, "template.jst.seam2");
//$NON-NLS-1$
+// node.put(SeamProjectPreferences.SEAM_CONFIG_TEMPLATE,
"template.jst.seam2"); //$NON-NLS-1$
node.put(SeamProjectPreferences.RUNTIME_CONFIG_FORMAT_VERSION,
RUNTIME_CONFIG_FORMAT_VERSION);
node.put(SeamProjectPreferences.JBOSS_AS_DEFAULT_DEPLOY_AS, "war");
//$NON-NLS-1$
node.put(SeamProjectPreferences.HIBERNATE_DEFAULT_DB_TYPE, "HSQL");
//$NON-NLS-1$
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2009-04-14
10:33:00 UTC (rev 14733)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2009-04-14
11:30:02 UTC (rev 14734)
@@ -73,6 +73,9 @@
import org.jboss.tools.jst.web.server.RegistrationHelper;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamProjectPreferences;
+import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
+import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.AntCopyUtils;
import org.jboss.tools.seam.internal.core.project.facet.DataSourceXmlDeployer;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
@@ -121,11 +124,15 @@
return firstPage;
}
+ private static final String templateJstSeam1 = "template.jst.seam";
//$NON-NLS-1$
+ private static final String templateJstSeam2 = "template.jst.seam2";
//$NON-NLS-1$
+ private static final String templateJstSeam21 = "template.jst.seam21";
//$NON-NLS-1$
+
private static final Map<String, String> templates = new HashMap<String,
String>();
static {
- templates.put("jst.seam.preset", "template.jst.seam");
- templates.put("jst.seam2.preset", "template.jst.seam2");
- templates.put("jst.seam21.preset", "template.jst.seam21");
+ templates.put("jst.seam.preset", templateJstSeam1); //$NON-NLS-1$
+ templates.put("jst.seam2.preset", templateJstSeam2); //$NON-NLS-1$
+ templates.put("jst.seam21.preset", templateJstSeam21); //$NON-NLS-1$
}
private void setSeamConfigTemplate(String seamConfigTemplate) {
@@ -225,6 +232,20 @@
protected IFacetedProjectTemplate getTemplate() {
seamConfigTemplate =
SeamCorePlugin.getDefault().getPluginPreferences().getString(SeamProjectPreferences.SEAM_CONFIG_TEMPLATE);
+ if(seamConfigTemplate==null || seamConfigTemplate.length()==0) {
+ SeamRuntime runtime = SeamRuntimeManager.getInstance().getLatestSeamRuntime();
+ if(runtime!=null) {
+ if(runtime.getVersion()==SeamVersion.SEAM_1_2) {
+ seamConfigTemplate = templateJstSeam1;
+ } else if(runtime.getVersion()==SeamVersion.SEAM_2_0) {
+ seamConfigTemplate = templateJstSeam2;
+ } else {
+ seamConfigTemplate = templateJstSeam21;
+ }
+ } else {
+ seamConfigTemplate = templateJstSeam21;
+ }
+ }
return ProjectFacetsManager.getTemplate(seamConfigTemplate);
}